0
我要寻找一个regualr表达VS2010解决方案文件找到的String.Empty与string.IsNullOrEmpty正则表达式查找和替换
更换为前if (strText != string.Empty)
到string.IsNullOrEmpty(strText)
我要寻找一个regualr表达VS2010解决方案文件找到的String.Empty与string.IsNullOrEmpty正则表达式查找和替换
更换为前if (strText != string.Empty)
到string.IsNullOrEmpty(strText)
在VS2012这已经成为轻松了很多,因为所使用的正则表达式语言进行了改进了不少:
搜索:
\b(?<variable>[\w_-]+)\s*==\s*string.Empty
替换:
string.IsNullOrEmpty(${variable})
的总体思路是Visual Studio 2010中相同:
搜索:
{[A-Za-z0-9_\-]+}:b*==:b*string\.Empty
替换:
string.IsNullOrEmpty(\1)
正如其他人所指出的,是一定要进行单元测试来验证你没有破坏任何东西,或者检查每个替代品是否确定。
在替换源代码中的检查之前,您可以查看[string.IsNullOrWhiteSpace](http://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace.aspx) – Habib