XML technologies / Regular expressions / Features and dialects / Maintenance⟦U+0003⟧ of regular expressions
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
The chapter’s second introductory topic was how programs syntactically package regexes. Each program needs some way to be told, “Here is a regex; perform this operation with it.” egrep is simple: the regex is a command-line argument. Single quotes, as in Introduction to regular expressions, are used not for egrep itself, but to prevent the shell interpreting metacharacters. Languages and other tools with broader regex usage need more elaborate packaging to identify the regex and the requested action.
Next, consider how matching results are used. egrep always does the same simple thing: prints matching lines. But Extended introductory examples showed much more interesting possibilities. The two basic operations are matching , which checks a string and may extract information, and search and replace, substitution, which changes the input string based on matches. Both have many variations, as do their interfaces in individual languages.
Programming languages essentially use three models: integrated, procedural and object-oriented. In the first, regex operators are built into the language, as in Perl. In the other models, regexes are not part of the language itself. They are strings passed to ordinary functions, which interpret them and perform the requested action. Most languages other than Perl use this approach: Java, the .NET languages, Tcl, Python, PHP, Emacs Lisp and Ruby.
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