Saturday, 23 July 2022

Why doesn't positive lookahead work as first capture group?

I'm using the following regex;

((?:_missing_:|_exists_:)[a-z0-9]+)|(([a-z0-9]+)(?=:))

To match a lucene query string;

_missing_:title age:(>=10 AND < 20) AND age:123 AND _exists_:title123

The first non-capture group is not respected and returns _missing_:title and not title. Using a positive lookahead makes the entire regex fail to match anything.

It should return the following array;

['title', 'age', 'age', 'title123']


from Why doesn't positive lookahead work as first capture group?

No comments:

Post a Comment