4 ms·
That was a fantastic demonstration of what backtracking meant. Thank you John for your in depth description of what went wrong. As a follow up, would something
by cordite 7y ago
That was a fantastic demonstration of what backtracking meant. Thank you John for your in depth description of what went wrong.
As a follow up, would something like `[^=]=.` be a better capture group regex?
- jalada 7y agoYes. I think HN stole your asterisks. You meant: /.*=.*/ becomes /[^=]*=.*/ That is, zero or more 'not-equals-sign-characters', followed by an equals sign. Where the first regex is 57 steps for x=xxxxxxxxxxxxxxxxxxxxxxxx, the second is just 7. Avoid using greedy .* for backtracking regex engines! Give your greedy regex engine the hints it needs to do what it does best.