转一篇关于正则表达式的!
http://www.cnblogs.com/zhzkl/archive/2006/10/01/519868.html
自己写的正则表达式特殊字符转义函数
private string TranslateRegexString(string str)
{
string[] reserveChars = new string[] {"\\", ".", "$", "^", "[", "(", ")", "]", "{", "}", "*", "+", "?" };
string[] replaceChars = new string[] {"\\\\", @"\.", @"\$", @"\^", @"\[", @"\(", @"\)", @"\]", @"\{", @"\}", @"\*", @"\+", @"\?" };
string reStr = str;
for (int i = 0; i < reserveChars.Length; i++)
reStr = reStr.Replace(reserveChars[i], replaceChars[i]);
return reStr;
}
自己写的正则表达式特殊字符转义函数
private string TranslateRegexString(string str)
{
string[] reserveChars = new string[] {"\\", ".", "$", "^", "[", "(", ")", "]", "{", "}", "*", "+", "?" };
string[] replaceChars = new string[] {"\\\\", @"\.", @"\$", @"\^", @"\[", @"\(", @"\)", @"\]", @"\{", @"\}", @"\*", @"\+", @"\?" };
string reStr = str;
for (int i = 0; i < reserveChars.Length; i++)
reStr = reStr.Replace(reserveChars[i], replaceChars[i]);
return reStr;
}
将想法付诸于实践,借此来影响他人是一个人存在的真正价值