2010-03-09 34 views

回答

9

在这个site上讲的.NET中没有与\ Q ... \ E语法直接等价的东西。

相反,你可以使用Regex.Escape方法:

逃逸最小集的 字符(\,*,+,|,{,[,(,), ^,$? ,#,和空格)由 替换它们的转义 代码。

2

可以使用Regex.Escape

string input = "any +idea? dude";  
string pattern = @"\ *" + Regex.Escape("+idea?") + @"\ *" 
Regex Expression = new Regex(pattern); 

MatchCollection match = Expression.Matches(input); 
相关问题