mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Docs for /F modifier and matching delimeters.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@39996 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
6df83eb27d
commit
d9990a9d99
1 changed files with 30 additions and 3 deletions
|
@ -6,10 +6,11 @@
|
|||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
The ending delimiter may be followed by various modifiers that
|
||||
|
@ -23,6 +24,7 @@
|
|||
<listitem><simpara>/<\/\w+>/</simpara></listitem>
|
||||
<listitem><simpara>|(\d{3})-\d+|Sm</simpara></listitem>
|
||||
<listitem><simpara>/^(?i)php[34]/</simpara></listitem>
|
||||
<listitem><simpara>{^\s+(\s+)?$}</simpara></listitem>
|
||||
</itemizedlist>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -362,6 +364,13 @@ part 3: </a>
|
|||
code string, otherwise PHP will complain about a parse error at
|
||||
the line containing <function>preg_replace</function>.
|
||||
</para>
|
||||
<para>
|
||||
</literal>/F</literal> modifier means that the
|
||||
<parameter>replacement</parameter> 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.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Replacing several values</title>
|
||||
|
@ -694,7 +703,8 @@ $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array);
|
|||
If this modifier is set, <function>preg_replace</function>
|
||||
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 <literal>/F modifier</literal>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Only <function>preg_replace</function> uses this modifier;
|
||||
|
@ -702,6 +712,23 @@ $fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array);
|
|||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><emphasis>F</emphasis></term>
|
||||
<listitem>
|
||||
<simpara>
|
||||
If this modifier is set, <function>preg_replace</function>
|
||||
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 <literal>/e modifier</literal>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Only <function>preg_replace</function> uses this modifier;
|
||||
it is ignored by other PCRE functions. This modifier was added in PHP
|
||||
4.0.4.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><emphasis>A</emphasis> (PCRE_ANCHORED)</term>
|
||||
<listitem>
|
||||
|
|
Loading…
Reference in a new issue