XML technologies / Regular expressions / PHP / “Missing” preg functions
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
The preg functions in PHP cover a broad range, but I have repeatedly encountered situations where they fall short. We have already seen my improved version of preg_match (see the box An empty match or no match).
Another poorly covered situation is when a regular expression comes from an external source, such as a file or web-form input, rather than a literal string in the program. The next section shows how tricky it can be to process such a string correctly before safely using it as a pattern argument.
Before using a regex, it is generally wise to check its syntax. We will cover that too.
Like all code examples, those on the following pages are published on my website.
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