0

How do I write a regex expression that matches these lines

<color>blue</color>
<color>green</color>
<color>blackish</color>
<color>offblack</color>

But not this

<color>black</color>
Ben Dover
  • 1
  • 1
  • 2
    Possible duplicate of [Regular expression that doesn't contain certain string](https://stackoverflow.com/questions/717644/regular-expression-that-doesnt-contain-certain-string) – JeffUK Jun 27 '17 at 15:01
  • should it only match `n` (except where n = black) or ANY line except black (I.e. would `I like turtles`) be match or a non-match – JeffUK Jun 27 '17 at 15:03
  • Possible duplicate of [Negative lookahead Regular Expression](https://stackoverflow.com/questions/6851921/negative-lookahead-regular-expression) – dloeda Jun 27 '17 at 15:33

1 Answers1

1

^<color>((?!black).*?|black.+?)</color>$

Click here for a test / explanation

Jay
  • 3,640
  • 12
  • 17