Regex to match all words except a given list

后端 未结 6 938
Happy的楠姐
Happy的楠姐 2020-12-08 21:15

I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT.

I have tried the following for the match par

6条回答
  •  生来不讨喜
    2020-12-08 21:54

    (?!\bnot\b|\band\b|\bor\b|\b\"[^"]+\"\b)((?<=\s|\-|\(|^)[^\"\s\()]+(?=\s|\*|\)|$))
    

    I use this regex to find all words that are not within double quotes or are the words "not" "and" or "or."

提交回复
热议问题