Erik Corry (2015-10-09T08:52:09.000Z)
d at domenic.me (2015-10-12T20:38:11.472Z)
I made an implementation of .NET-style variable length lookbehinds. It's not in a JS engine, but it's in a very simple (and very slow) ES5-compatible regexp engine that is used in the tiny Dart implementation named Fletch. No unicode issues arise since this engine does not support /u, but I don't expect any issues since it's not trying to second-guess the length of the string matched by an expression. Needs a lot more tests, but it seems to work OK and was surprisingly simple to do. Basically: * All steps in the input string are reversed, so if you would step forwards you step backwards. * Check for start of string instead of end of string. * Test against the character to the left of the cursor instead of to the right. * The parts of the Alternative (see the regexp grammar in the standard) are code-generated in reverse order. Code is here: https://codereview.chromium.org/1398033002/