From d9990a9d99ffd4ce0a3e51d67f64ec1dd1c70c88 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Mon, 22 Jan 2001 22:27:41 +0000 Subject: [PATCH] Docs for /F modifier and matching delimeters. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@39996 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/pcre.xml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/functions/pcre.xml b/functions/pcre.xml index c25ae91463..f6e50e1d33 100644 --- a/functions/pcre.xml +++ b/functions/pcre.xml @@ -6,10 +6,11 @@ The syntax for patterns used in these functions closely resembles Perl. The expression should be enclosed in the delimiters, a - forward slash (/), for example. Any character can be used for + forward slash (/), for example. Any character can be used for delimiter as long as it's not alphanumeric or backslash (\). If the delimiter character has to be used in the expression itself, - it needs to be escaped by backslash. + it needs to be escaped by backslash. Since PHP 4.0.4, you can also use + Perl-style (), {}, [], and <> matching delimiters. The ending delimiter may be followed by various modifiers that @@ -23,6 +24,7 @@ /<\/\w+>/ |(\d{3})-\d+|Sm /^(?i)php[34]/ + {^\s+(\s+)?$} @@ -362,6 +364,13 @@ part 3: </a> code string, otherwise PHP will complain about a parse error at the line containing preg_replace. + + /F modifier means that the + replacement is taken to be a function name. This + function will be called and passed an array of matched elements in the + subject string. The function should return the replacement string. This + modifier was added in PHP 4.0.4. + Replacing several values @@ -694,7 +703,8 @@ $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array); If this modifier is set, preg_replace does normal substitution of backreferences in the replacement string, evaluates it as PHP code, and uses the - result for replacing the search string. + result for replacing the search string. This modifier cannot be used along + with /F modifier. Only preg_replace uses this modifier; @@ -702,6 +712,23 @@ $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array); + + F + + + If this modifier is set, preg_replace + treats the replacement parameter as a function name that should be called + to provide the replacement string. The function is passed an array of + matched elements in the subject string. This modifier cannot be used along + with /e modifier. + + + Only preg_replace uses this modifier; + it is ignored by other PCRE functions. This modifier was added in PHP + 4.0.4. + + + A (PCRE_ANCHORED)