regex - Why are lookbehind assertions not supported in Javascript? -


recently realized (by embarrassment) regex lookbehind assertions were not possible in javascript.

what (factual) reason absence assertion seemingly common?

i realize there alternate ways achieve same thing perhaps, although basic semantics @ work forbid functionality, or exactly?

it seems regex testing tools out there generate javascript code regex patterns seem ignore fact — strikes me bit odd.

it looks @ time, brendan eich wasn't aware of existence (because netscape built on older version of perl):

this 1998, netscape 4 work did in '97 based on perl 4(!), proposed ecma tc39 tg1 (the js group -- things different then, including capitalization) based on perl 5. didn't everything, , had rationalize obvious quirks.

i don't remember lookbehind (which emerged in perl 5.005 in july '98) being left out on purpose. waldemar may recall more, i'd handed him js keys inside netscape.com go mozilla.org.

if game write proposal or mini-spec (in style of es5 even), let me know. i'll chat other tc39'ers next week this.

/be

there have been bunch of different on mailing list attempts include it, still seems pretty complex feature performance-wise, because ecmascript regular expressions backtracking based , backtracking needed in lookbehind when working capturing groups. can lead problems such catastrophic backtracking when used incorrectly.

at point suggested es6/es 2015, never made draft, let alone specification. in last post in discussion, seems nobody took task of implementing it. if feels called write implementation, can sign es discuss list , propose it.

update may 2015:

in may 2015, nozomu katō has proposed es7 look-behind implementation.

update september 2015:

regex look-behind added stage 0 proposal.

update may 2017:

the proposal @ stage 3. means @ least 2 browsers need implement become part of next ecmascript standard. @martixy mentioned in comments, chrome has implemented behind js experimental flag.


Comments