Search code examples
regexalgorithmsqueakdfanfa

How to figure out if a regex implementation uses DFA or NFA?


I'm facing the question, whether a certain regex implementation is based on a DFA or NFA.

What are the starting points for me to figure this out. One could also ask: What am I looking for? What are the basic patterns and / or characteristics? A good and explanatory link or a little comparisons (even if not directly dedicated to regex) is perfectly fine.


Solution

  • I think you mean "regex implementation" rather than algorithm (in the usual sense).

    You could test with know expressions that are known to cause problems with one approach or the other. Also looking for features that are easier to implement in one or the other (this is not a reliable approach – the developers of regex engines find new ways to implement previously hard things).

    Normally the answer is to read the documentation, or look in a known reference ("Mastering Regular Expressions" documents many popular cases). Finally why not ask the authors?