|Fast NFA engine anyone? firstname.lastname@example.org (Remo D.) (2006-04-21)|
|Re: Fast NFA engine anyone? email@example.com (Russ Cox) (2006-04-22)|
|Re: Fast NFA engine anyone? firstname.lastname@example.org (Remo D.) (2006-04-22)|
|Re: Fast NFA engine anyone? cfc@shell01.TheWorld.com (Chris F Clark) (2006-04-23)|
|Re: Fast NFA engine anyone? email@example.com (2006-04-23)|
|Re: Fast NFA engine anyone? Danny.Dube@ift.ulaval.ca (2006-05-11)|
|Re: Fast NFA engine anyone? firstname.lastname@example.org (Remo D.) (2006-05-12)|
|[1 later articles]|
|From:||"Remo D." <email@example.com>|
|Date:||21 Apr 2006 23:45:16 -0400|
|Organization:||MC-link SpA InterNetNews site|
|Posted-Date:||21 Apr 2006 23:45:16 EDT|
I'm writing a program to match a list of regexp against a file to
check which one matches and, in case, extract substring from the
matching text for further processing. All regexp are anchored (i.e. I
only need to find matches at the beginning of the line).
The first implementation I wrote uses a NFA representation for the
regexps. Now I'm looking for something faster.
I have the impression that going with a DFA representation is not a
good idea. I feel that the time I will have to spend extracting the
substring from the matching text will wipe out any benefit I will get (I
might be wrong, of course).
Being all the regexps anchored, there should be a easier way!
Consider that I would even sacrifice some of the expressiveness of
regexp. I already dropped the operator | without any impact on the final
I hope you can help me to answer the following questions.
Is there an optimized implementation of a NFA engine (or a paper
describing how to do it)?
Is there any work done on comparing NFA and DFA when regexp are
anchored (if it makes a difference as I suspect)?
There could be a better approach (e.g. SNOBOL-like pattern matching
Any help would be gratefully appreciated!
[I think you're wrong about DFAs. If your patterns are really all anchored,
the match is the string from the beginning of the line to the point where
the match succeeded. -John]
Return to the
Search the comp.compilers archives again.