 |
|
ss
Oracle Tips by Burleson |
mixed preg_match
( string pattern, string subject [, array &matches [, int flags [, int
offset]]])
This searches subject for a match to the
regular expression given in pattern. If matches is
provided, it is filled with the results of search. $matches[0]
contains the text that matched the full pattern, $matches[1]
has the text that matched the first captured parenthesized
sub-pattern, and so on.
The function above uses practically the same
pattern matching syntax as Perl because it uses PCRE (Perl Compatible
Regular Expressions) library as the pattern matching engine. The
preg_matchfunction is not the
only PCRE function implemented in PHP, it is one of several functions.
The other PCRE functions are:
-
preg_grep
-
preg_match_all
-
preg_match
-
preg_quote
-
preg_replace_callback
-
preg_replace
-
preg_split
These functions are very well documented in the
online documentation on the PHP home page,
http://www.php.net.
Regular expression syntax is quite an extensive
subject covered in several books and is beyond the scope of this book.
Detailed documentation for PCRE library can be found on
http://www.pcre.org. Probably, the
best introductory document for Perl’s regular expression syntax is the
legendary “llama book”, Learning Perl by Randal Schwartz and Tom
Phoenix.
Mastering regular expressions is wholeheartedly
recommended not just because they are extremely useful in scripting
languages like PHP and Perl; they are also supported by the latest and
the greatest version of Oracle RDBMS,
Oracle 10g.
This completes supplied functions in this chapter.
The additional functions are introduced later in this book and are
explained with detailed examples. PHP5 is a scripting language that
borrows its philosophy from C. The syntax is extremely simple, yet
very powerful, while the additional complexities a placed in the
functions instead in the syntax. One of the things that make Perl
rather complex and difficult to learn is its syntax with a multitude
of operators, expression syntaxes, built-in variables and language
idioms. PHP has none of that. Complexities of regular expressions are
placed in functions, as is the case with most of other things.
See
code depot for complete scripts
The above book excerpt is from:
Easy Oracle
PHP
Create Dynamic Web Pages with Oracle Data
ISBN
0-9761573-0-6
Mladen Gogala
http://www.rampant-books.com/book_2005_2_php_oracle.htm
|