What characters need to be escaped in .NET Regex?

后端 未结 4 767
伪装坚强ぢ
伪装坚强ぢ 2020-12-15 03:18

In a .NET Regex pattern, what special characters need to be escaped in order to be used literally?

4条回答
  •  我在风中等你
    2020-12-15 03:38

    See the MSDN documentation here: http://msdn.microsoft.com/en-us/library/az24scfc.aspx#character_escapes

    The problem with a complete list is that it depends on context. For example . must be escaped, unless it is enclosed in brackets, as in [.]. ] technically does not need to be escaped, unless it is preceded by [. - has no special meaning, unless it's inside of brackets, as in [A-Z]. = has no special meaning unless it is preceded by ? as in (?=).

提交回复
热议问题