?– Note POSIX stands for Portable Operating System Interface for Unix, and is representative of a set of
standards originally intended for Unix-based operating systems. POSIX regular expression syntax is an
attempt to standardize how regular expressions are implemented in many programming languages.
The simplest regular expression is one that matches a single character, such as g,
which would match strings such as gog, haggle, and bag. You could combine several
letters together to form larger expressions, such as gan, which logically would match
any string containing gan: gang, organize, or Reagan, for example.
CHAPTER 9 ?– S TRINGS AND REGULAR EXPRESS IONS 233
You can also test for several different expressions simultaneously by using the pipe (|)
character. For example, you could test for php or zend via the regular expression
php|zend.
Before getting into PHP??™s POSIX-based regular expression functions, let??™s review
three methods that POSIX supports for locating different character sequences: brackets,
quantifiers, and predefined character ranges.
Brackets
Brackets ([]) are used to represent a list, or range, of characters to be matched. For
instance, contrary to the regular expression php, which will locate strings containing
the explicit string php, the regular expression [php] will find any string containing the
character p or h. Several commonly used character ranges follow:
??? [0-9] matches any decimal digit from 0 through 9.
Pages:
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310