在C#的正则表达式中是否有与\Q ... \E等价的操作?我找不到它。
在.NET中,没有直接等效于\ Q ... \ E语法的方法,这在此网站中已经说明。
相反,您可以使用Regex.Escape方法:
通过将字符的转义代码替换为它们的转义代码,最小限度地转义一组字符(\,*,+,?,|,{,[,(),^,$,.,#和空格)。
string input = "any +idea? dude";
string pattern = @"\ *" + Regex.Escape("+idea?") + @"\ *"
Regex Expression = new Regex(pattern);
MatchCollection match = Expression.Matches(input);