Saturday, October 13, 2018

Negative lookahead in Text.Regex.Posix

Leave a Comment

I am trying to use negative lookahead – standart regex-posix practice:

"foobarbaz" =~ "^(?!.*bar).*$" :: Bool 

and getting error *** Exception: user error (Text.Regex.Posix.String died: (ReturnCode 13,"repetition-operator operand invalid"))

How can I use negative lookahead in Haskell?

1 Answers

Answers 1

Disclaimer: there are too many GREP dialects!

Your original GREP works on InDesign (it uses a slightly amended boost implementation); so does this alternative:

^((?!bar).)*$ 

i.e., try to match (?!bar). on each character in turn.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment