1

I need a regular expression matching every string except for a given one (say, "hello"). In my framework negative look-ahead and look-behind are not supported, so I can't use the simple:

"^(?!hello$).*"

Is there an equivalent not using look-behind or look-ahead?

I need a string to not match only if it is exactly the given word, not if it simply contains it.

Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185
  • This is an example of [how to match any string but `foo`](https://regex101.com/r/jC8nB0/25). Use the logic to create a pattern for your case... But perhaps, there are better ways. Usually, there are better ways. – Wiktor Stribiżew Jul 21 '17 at 16:06
  • I'm using confd/yang and it looks like it doesn't support look-ahead or look-behind http://discuss.tail-f.com/t/regex-assertions-in-yang-pattern/644 – Ricky Robinson Jul 21 '17 at 16:17
  • @RickyRobinson the accepted answer that Wiktor has linked does not fit your use case, but try having a look through the other answers to that question. The second answer down contains a solution not using look-aheads or look-behinds – Tom Wyllie Jul 21 '17 at 16:29

0 Answers0