Why doesn't JavaScript have lookbehinds?

406 Views Asked by At

I know there are various work-arounds but it seems strange that a pretty common/helpful regular expression feature isn't available in JavaScript.

Is there any reason for this (performance issues, implementation issues, etc.) or was it not added in the beginning and now it is too late/not needed?

3

There are 3 best solutions below

1
On

Simple, it just doesn't.

Languages can't have all the features available in other languages.

Why doesn't JavaScript have static typing? How come it doesn't support multiple inheritance? It's just built the way it is.

0
On

Why? The JavaScript regular expression engine clearly does not support lookbehinds.

However, you can simulate the use of lookbehind using the XRegExp library or with String.replace() and optional capturing groups.

0
On

Because not enough JS developers have marched in to the offices of Netscape then ECMA International with placards reading:

We Demand Lookbehinds Now! The Time is Right for Lookbehinds!

But it's not too late. You can start a movement, and many people who follow the regex tag will be right behind you.

Lead us on, champ! :)