Does lookaround affect which languages can be matched by regular expressions?

The answer to the question you ask, which is whether a larger class of languages than the regular languages can be recognised with regular expressions augmented by lookaround, is no. A proof is relatively straightforward, but an algorithm to translate a regular expression containing lookarounds into one without is messy. First: note that you can … Read more

Regex lookahead, lookbehind and atomic groups

Examples Given the string foobarbarfoo: bar(?=bar) finds the 1st bar (“bar” which has “bar” after it) bar(?!bar) finds the 2nd bar (“bar” which does not have “bar” after it) (?<=foo)bar finds the 1st bar (“bar” which has “foo” before it) (?<!foo)bar finds the 2nd bar (“bar” which does not have “foo” before it) You can … Read more