Skip to main content

http://swtch.com/~rsc/regexp/regexp1.htmlhttps://swtch.com/~rsc/regexp/regexp1.html gives you a good overview of the differences between NFAs and DFAs, as well as concrete information for how to make DFAs do things that most people don't think that they can do (find the boundaries of subpatterns). The reason why most people don't know that is possible is becausethat most programmers get their information from Jeffrey Friedl, who got the theory wrong in an otherwise wonderful book on regular expressions. (I recommend Mastering Regular Expressions because it is a good practical introduction to them, but the theory is not correct.)

If you want the simple version, NFAs are simpler to implement and allow you to implement more features, at the cost of having some pathological cases where they will take exponential time to figure out that there is no match. (In practice, won't match before the Sun blows up.) By contrast, DFAs offer performance guarantees, but some pathological regular expressions can take an extremely large amount of memory to express as a DFA.

http://swtch.com/~rsc/regexp/regexp1.html gives you a good overview of the differences between NFAs and DFAs, as well as concrete information for how to make DFAs do things that most people don't think that they can do (find the boundaries of subpatterns). The reason why most people don't know that is possible is because most programmers get their information from Jeffrey Friedl, who got the theory wrong in an otherwise wonderful book on regular expressions. (I recommend Mastering Regular Expressions because it is a good practical introduction to them, but the theory is not correct.)

If you want the simple version, NFAs are simpler to implement and allow you to implement more features, at the cost of having some pathological cases where they will take exponential time to figure out that there is no match. (In practice, won't match before the Sun blows up.) By contrast DFAs offer performance guarantees, but some pathological regular expressions can take an extremely large amount of memory to express as a DFA.

https://swtch.com/~rsc/regexp/regexp1.html gives you a good overview of the differences between NFAs and DFAs, as well as concrete information for how to make DFAs do things that most people don't think that they can do (find the boundaries of subpatterns). The reason why most people don't know that is possible is that most programmers get their information from Jeffrey Friedl, who got the theory wrong in an otherwise wonderful book on regular expressions. (I recommend Mastering Regular Expressions because it is a good practical introduction to them, but the theory is not correct.)

If you want the simple version, NFAs are simpler to implement and allow you to implement more features, at the cost of having some pathological cases where they will take exponential time to figure out that there is no match. (In practice, won't match before the Sun blows up.) By contrast, DFAs offer performance guarantees, but some pathological regular expressions can take an extremely large amount of memory to express as a DFA.

Source Link
btilly
  • 18.3k
  • 1
  • 50
  • 76

http://swtch.com/~rsc/regexp/regexp1.html gives you a good overview of the differences between NFAs and DFAs, as well as concrete information for how to make DFAs do things that most people don't think that they can do (find the boundaries of subpatterns). The reason why most people don't know that is possible is because most programmers get their information from Jeffrey Friedl, who got the theory wrong in an otherwise wonderful book on regular expressions. (I recommend Mastering Regular Expressions because it is a good practical introduction to them, but the theory is not correct.)

If you want the simple version, NFAs are simpler to implement and allow you to implement more features, at the cost of having some pathological cases where they will take exponential time to figure out that there is no match. (In practice, won't match before the Sun blows up.) By contrast DFAs offer performance guarantees, but some pathological regular expressions can take an extremely large amount of memory to express as a DFA.