Unmatch complete words if a negative lookahead is satisfied

后端 未结 2 2001
慢半拍i
慢半拍i 2021-01-22 12:13

I need to match only those words which doesn\'t have special characters like @ and :. For example:

  1. git@github.com shouldn\'t
2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-22 12:33

    You can use negative lookbehind and negative lookahead patterns around a word pattern to make sure that the word is not preceded or followed by a non-space character, or in other words, to make sure that it is surrounded by either a space or a string boundary:

    (?

    Demo: https://regex101.com/r/cjhUUM/2

提交回复
热议问题