Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

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.

share|improve this question

closed as off-topic by MichaelT, Ixrec, durron597, amon, gnat Aug 30 at 18:31

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

4  
I'm voting to close this question as off-topic because it is asking us to guess as to the motivations of the designers goals and constraints. –  MichaelT Aug 30 at 16:45
    
mmm, I'll try to rephrase my question so that it's asking for people who actually know the answer - supposing that there's an actual answer –  Jivan Aug 30 at 16:47
3  
Why don't you ask on a Javascript design mailing list? Your question would depend purely on Brendan Eich (or one of the other designers) stumbling across it rather than drawing from the expert knowledge of the community. Asking a question that only the designers of a language can properly answer doesn't make for a good question in the Q&A format as all of our answers would be guesses (with no way to tell which one was right). –  MichaelT Aug 30 at 16:49
    
@MichaelT Unless one of the designers was a member on Programmers and actually saw this question, as unlikely as that is. –  Chris Cirefice Aug 30 at 17:32
    
okay so the answer to this question seems to be "people don't know, except those who made the decision". This in itself was worth asking the question. –  Jivan Aug 30 at 19:23