Many regular expression libraries do only allow strict expressions to be used in look behind assertions like:
- only match strings of the same fixed length:
(?<=foo|bar|\s,\s)
(three characters each) - only match strings of fixed lengths:
(?<=foobar|\r\n)
(each branch with fixed length) - only match strings with a upper bound length:
(?<=\s{,4})
(up to four repetitions)
The reason for these limitations are mainly because those libraries can’t process regular expressions backwards at all or only a limited subset.
Another reason could be to avoid authors to build too complex regular expressions that are heavy to process as they have a so called pathological behavior (see also ReDoS).
See also section about limitations of look-behind assertions on Regular-Expressions.info.