regex : how to match word ending with parentheses “)”

前端 未结 3 1111
礼貌的吻别
礼貌的吻别 2020-12-22 08:32

I want to match string ending with \')\' . I use pattern :

 \"[)]\\b\" or \".*[)]\\b\"

It should match the string :

x=main2         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-22 09:14

    The \b only matches a position at a word boundary. Think of it as a (^\w|\w$|\W\w|\w\W) where \w is any alphanumeric character and \W is any non-alphanumeric character. The parenthesis is non-alphanumeric so won't be matched by \b.

    Just match a parethesis, followed by the end of the string by using \)$

提交回复
热议问题