regex - How can I simulate a negative lookup in a regular expression -
i have following regular expression includes negative ahead. unfortunately tool i'm using not support regular expressions. i'm wondering if possible achieve negative ahead behaviour without using one.
here regular expression:
(?<![abcdeq]|\[|\]|\w\w\d)(\d+["+-]?)(?!be|aq|n)(?:.*)
here working sample data on regex101.com:
see expression on regex101.com
i'm using tool called alteryx. documentation indicates uses perl, however, whatever reason ahead not work.
alteryx appears use boost library regex support, , boost documentation says lookbehind expressions must have fixed length. it's more restrictive php (pcre), allows use alternation in lookbehind, long each branch fixed-length. that's easy enough around: use multiple lookbehinds:
(?<![abcdeq])(?<!\[)(?<!\])(?<!\w\w\d)(\d+["+-]?)(?!be|aq|n)(?:.*)
that regex works me in boost-powered regex tester, yours doesn't. compress little more putting square brackets inside character set:
(?<![][abcdeq])(?<!\w\w\d)(\d+["+-]?)(?!be|aq|n)(?:.*)
the right bracket treated literal when it's first character listed, , left bracket never special (though other flavors have different rules).
here's updated demo.
Comments
Post a Comment