Is it possible to compile regex rules in Node.js for faster usage?
2 Answers
V8 compiles regexes automatically. See http://www.scribd.com/doc/16921039/V8-Internals-Building-a-High-Performance-JavaScript-Engine
Node.js is just JavaScript running on V8 so you really only have what V8 provides, namely:
var r = new RegExp("abc", 'i');
V8 will do it's own optimization, probably even on inline regexes.
1 Comment
Esailija
If you are using regex literal such as
/abc/i, the new RegExp is redundant
var pattern = /regex/;?