regex'literal'在regex中的含义 [英] regex 'literal' meaning in regex
本文介绍了regex'literal'在regex中的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法按原样处理正则表达式字符串的一部分?
is there a way to treat a section of your regex string 'as is'?
即我要匹配字面模式:在某些文本中为"[^ * .. @/w $ [{"(夸张的示例,但是您明白我的意思了)...我可以将整个部分括在某些东西中吗?/p>
I.e. I want to match for the literal pattern: "[^*..@/w$[{" in some text (exaggerated example, but you see what I mean)... Can I just enclose the whole bit in something?
推荐答案
使用 Regex.Escape
.
请参阅 http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape.aspx
这篇关于regex'literal'在regex中的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文