Most regex implementations allow a lookbehind
condition, so that such an expression:
(?<=hello )world
will match world
only if it is preceded by hello
. This functionality can prove useful at times, in particular when you can't or don't want to use capturing groups.
However, JavaScript notoriously doesn't offer this possibility. It allows lookahead
, but not lookbehind
.
My question concerns the rationale behind this "limitation".
- Is it purely technical? Perhaps the internals of
lookbehind
were considered too expensive for browsers by the time JavaScript regex implementation was designed - Is it because of political issues? Like with some other aspects of JavaScript who were not taken as far as they could have because of, say, Microsoft pushing back in the 2000's
- Is it purely deliberate? I heard many programmers saying they considered the use of
lookbehind
as evil in most cases, so that it could have been skipped on purpose by this implementation's designers - Or perhaps, nobody really knows except the designers themselves?
EDIT: Not asking for guesses here. This question has been asked in the hope that somebody actually knows the answer.