How do I test against a large number of regular expressions quickly and know which one matched?
Posted
by Jack
on Stack Overflow
See other posts from Stack Overflow
or by Jack
Published on 2010-05-24T19:48:08Z
Indexed on
2010/05/24
19:51 UTC
Read the original article
Hit count: 192
I'm writing a program in .net where the user may provide a large number of regular expressions. For a given string, I need to figure out which regular expression matches that string (if more than one matches, I just need the first one that matches). However, if there are a large number of regular expressions this operation can take a very long time.
I was somewhat hoping there would be something similar to flex for .net that would allow me to specify a large number of regular expressions yet quickly (O(n) according to Wikipedia for n = len(input string)) figure out which regular expression matches.
Also, I would prefer not to implement my own regular expression engine :).
© Stack Overflow or respective owner