Regex to match a pattern, but exclude a set of words

后端 未结 2 621
忘了有多久
忘了有多久 2020-12-30 04:27

I have been looking through SO and although this question has been answered in one scenario:

Regex to match all words except a given list

It\'s not quite wha

2条回答
  •  遥遥无期
    2020-12-30 05:08

    Do you really require this in a single regex? If not, then the simplest implementation is just two regexes - one to check you don't match one of your forbidden words, and one to match your \w+, chained with a logical AND.

提交回复
热议问题