How do I match a square bracket literal using RegEx?

前端 未结 6 1927
灰色年华
灰色年华 2021-02-07 00:27

What\'s the regex to match a square bracket? I\'m using \\\\] in a pattern in eregi_replace, but it doesn\'t seem to be able to find a ]..

6条回答
  •  后悔当初
    2021-02-07 01:04

    In .Net you escape special characters by adding up a backslash; "\" meaning it would become; "["...

    Though since you normally do this in string literals you would either have to do something like this;

    @"\["
    

    or something like this;

    "\\["
    

提交回复
热议问题