在Text.Regex.Posix负先行

And*_*sov 7 regex haskell

我试图使用负前瞻 - 非标准正则表达式,POSIX的做法:

"foobarbaz" =~ "^(?!.*bar).*$" :: Bool
Run Code Online (Sandbox Code Playgroud)

并得到错误 *** Exception: user error (Text.Regex.Posix.String died: (ReturnCode 13,"repetition-operator operand invalid"))

如何使用负前瞻在Haskell?

usr*_*301 4

免责声明:GREP 方言太多了!

您原来的 GREP 在 InDesign 上运行(它使用了稍微修改的boost实现);这个替代方案也是如此:

^((?!bar).)*$
Run Code Online (Sandbox Code Playgroud)

即,尝试(?!bar).依次匹配每个字符。