jviereck / regjsparser

Parsing the JavaScript's RegExp in JavaScript.
http://www.julianviereck.de/regjsparser/
BSD 2-Clause "Simplified" License
79 stars 20 forks source link

Fix inline modifiers inside lookarounds #133

Closed stulov closed 2 months ago

stulov commented 1 year ago

Inside parseAtomAndExtendedAtom, (? used to be searched from the start of the string, rather than from the current position. So, trying to parse an expression containing nested lookarounds and inline modifiers (e.g., /(?<=(?i:un))parse(?=(?i:able))/) threw an error.

Didn't quite understand how the tests work, so didn't write one, sorry.

JLHwung commented 1 year ago

Didn't quite understand how the tests work, so didn't write one, sorry.

No worry. Can you add a test before

https://github.com/jviereck/regjsparser/blob/c622da77ffa1fa61ec2b36e19b17c8abfc3e6a9a/test/test-data-modifiers-group.json#L490

?

You can put the test regex as key and leave an empty object as value, then run node ./test/update-fixtures.js, it will update the actual AST as value and we can see if it works as expected.