XML technologies / Regular expressions / How regex engines work / More on greediness
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
Many problems and advantages of greediness affect both NFAs and DFAs. DFAs are always greedy and have no lazy constructs, which is why we have focused on greedy behavior. I will illustrate several points using an NFA. They also apply to DFAs, but for different reasons. DFAs are simply greedy; there is little more to say. Their behavior is persistent but dull to discuss. NFAs, however, behave differently depending on how creatively the regex is designed. Its author directly controls how matching proceeds. This offers advantages but also efficiency pitfalls, discussed in The art of writing regular expressions.
Despite these differences, matching results are usually the same. The next pages concern both engine types, but describe them from an NFA perspective. By the chapter’s end, you will understand when and why differences sometimes arise.
German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln
back to top