Re:Node.js in Flame Graphs
by koenigdavidmj on Wednesday November 19, 2014 @12:25PM
(#8631284)
There is a library (I think it is Google's re2) that supports throwing a bunch of regular expressions into a single structure, matching an input string against all of them at once, and answering which patterns matched the input string. This gets you route lookup in time linear to the input string (or if not linear, still better than checking all the patterns one after another).
[ Parent
| on HN ]
I use RE2 and currently achieve this with regular string concatenation. Do you know if they provide an API for doing this without concatenation, and if it would be faster?
Re:Node.js in Flame Graphs
by koenigdavidmj on Wednesday November 19, 2014 @05:50PM
(#8633211)
The header file is available at https://code.google.com/p/re2/source/browse/re2/set.h , and if I recall correctly, it merges all the regexes into one DFA so that it's faster than just concatenating all your patterns into one string.
re2 is described here: http://swtch.com/~rsc/regexp/regexp3.html