Match everything except for specified strings

前端 未结 7 1836
名媛妹妹
名媛妹妹 2020-11-22 14:25

I know that the following regex will match \"red\", \"green\", or \"blue\".

red|green|blue

Is there a straightforward way of making it mat

7条回答
  •  情书的邮戳
    2020-11-22 14:56

    Depends on the language, but there are generally negative-assertions you can put in like so:

    (?!red|green|blue)
    

    (Thanks for the syntax fix, the above is valid Java and Perl, YMMV)

提交回复
热议问题