The year is 2014. Most JS-parsers-in-JS use this pattern: function isValidRegExp(pattern) { try { new RegExp(pattern); return true; } catch { return false; } }
-
-
Here’s the horrible hack I landed in Esprima to support the /u flag (even in environments that didn’t yet support it): https://github.com/jquery/esprima/blob/c0dfa42da4da9fa242dac623278a082cb38edc20/src/scanner.ts#L1089-L1141 … It made its way into other parsers.
Show this thread -
It had known limitations, but it’s the best you can do without pulling in a full JS RegExp parser or validator, which seemed like overkill.
Show this thread -
https://github.com/shapesecurity/shift-regexp-acceptor-js … makes it look like it doesn’t have to be overkill. It’s an extremely lightweight JS RegExp acceptor that implements the full spec grammar.
Show this thread
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.