The below code (regexp-freeze.coffee) makes V8 lock up (both NodeJS and Chrome). It's my fault for nesting repeats (+
), but it would be nice if V8 (or it's RegExp library) detected this lock-up in some way - I don't think there's many situations in which it's okay for a RegExp to take more than a second on a 134byte string on a modern desktop computer...
How not to write it:
/`((?:[^\\`\n]+|(?:\\[^\n]))+)`/g
How to write it:
/`((?:[^\\`\n]|\\[^\n])+)`/g
NOTE: Only one repeat operator - no repeat nesting.
Whoops, I meant to remove that when I realised it was nothing to do with greediness, just nesting. Thanks for the heads up :)