Custom word boundaries in regular expression

前端 未结 1 1938
难免孤独
难免孤独 2021-01-06 04:03

I am trying to match words using a regular expression, but sadly the word boundary character (\\b) does not include enough characters for my taste, so I want to add more. (i

相关标签:
1条回答
  • 2021-01-06 04:12

    (no need to escape the + in a character class)

    The problem is that you use a negative lookahead first whereas you should use a negative lookbehind. Try:

    @"(?<![\w+])" + expression + @"(?![\w+])"
    
    0 讨论(0)
提交回复
热议问题