Here??™s
how you would use sql_regcase() to convert a string:
$version = "php 4.0";
echo sql_regcase($version);
// outputs [Pp] [Hh] [Pp] 4.0
?>
Regular Expression Syntax (Perl)
Perl has long been considered one of the most powerful parsing languages ever written,
and it provides a comprehensive regular expression language that can be used to search
and replace even the most complicated of string patterns. The developers of PHP felt
that instead of reinventing the regular expression wheel, so to speak, they should
make the famed Perl regular expression syntax available to PHP users.
Perl??™s regular expression syntax is actually a derivation of the POSIX implementation,
resulting in considerable similarities between the two. You can use any of the
240 CHAPTER 9 ?– STRINGS AND REGULAR EXPRESSIONS
quantifiers introduced in the previous POSIX section. The remainder of this section is
devoted to a brief introduction of Perl regular expression syntax. Let??™s start with a
simple example of a Perl-based regular expression:
/food/
Notice that the string food is enclosed between two forward slashes. Just as with
POSIX regular expressions, you can build a more complex string through the use of
quantifiers:
/fo+/
This will match fo followed by one or more characters. Some potential matches
include food, fool, and fo4. Here is another example of using a quantifier:
/fo{2,4}/
This matches f followed by two to four occurrences of o.
Pages:
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318