如何使用正则表达式将大写字母替换为小写字母? [英] How to replace upper case with lower case using regex?
本文介绍了如何使用正则表达式将大写字母替换为小写字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用小写字母替换变量名中的大写字母并添加空格
I need to replace upper case letter in variable name with lower case letter and add space
例如:
NotImplementedException
应该是未实现的异常
UnhandledException
应该是 UnhandledException
推荐答案
由于您未指定语言,因此在C#中给出一个示例.我相信您的语言会提供类似的功能.
Since you did not specify a language, I'll give an example in C#. I am sure your language will offer something like it.
String s = "NotImplementedException";
s = Regex.Replace(s, @"\B[A-Z]", m => " " + m.ToString().ToLower());
// s = "Not implemented exception"
这篇关于如何使用正则表达式将大写字母替换为小写字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文