svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml
| From: | Chris Wright | Date: | Tue, 29 Jul 2014 12:46:16 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-12664@lists.php.net to get a copy of this message | ||
daverandom Tue, 29 Jul 2014 12:46:16 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=334410
Log:
Clarify some details of using bracket-style delimiters in regular expression patterns
Patch suggested by Brandon Kelly (brandon@pixelandtonic.com)
Changed paths:
U phpdoc/en/trunk/reference/pcre/pattern.syntax.xml
Modified: phpdoc/en/trunk/reference/pcre/pattern.syntax.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/pattern.syntax.xml 2014-07-29 11:22:38 UTC (rev 334409)
+++ phpdoc/en/trunk/reference/pcre/pattern.syntax.xml 2014-07-29 12:46:16 UTC (rev 334410)
@@ -44,25 +44,12 @@
#^[^0-9]$#
+php+
%[a-zA-Z0-9_-]%
+{\w[\w0-9]*}
]]>
</programlisting>
</informalexample>
</para>
<para>
- In addition to the aforementioned delimiters, it is also possible to use
- bracket style delimiters where the opening and closing brackets are the
- starting and ending delimiter, respectively.
- <informalexample>
- <programlisting>
-<![CDATA[
-{this is a pattern}
-(foobar)
-<\d+>
-]]>
- </programlisting>
- </informalexample>
- </para>
- <para>
If the delimiter needs to be matched inside the pattern it must be
escaped using a backslash. If the delimiter appears often inside the
pattern, it is a good idea to choose another delimiter in order to increase
@@ -80,6 +67,26 @@
to specify the delimiter to be escaped.
</para>
<para>
+ In addition to the aforementioned delimiters, it is also possible to use
+ bracket style delimiters where the opening and closing brackets are the
+ starting and ending delimiter, respectively. <literal>()</literal>,
+ <literal>{}</literal>, <literal>[]</literal> and
<literal><></literal>
+ are all valid bracket style delimiter pairs.
+ <informalexample>
+ <programlisting>
+<![CDATA[
+(this [is] a (pattern))
+{this [is] a (pattern)}
+[this [is] a (pattern)]
+<this [is] a (pattern)>
+]]>
+ </programlisting>
+ </informalexample>
+ Bracket style delimiters do not need to be escaped when they are used as meta
+ characters within the pattern, but as with other delimiters they must be
+ escaped when they are used as literal characters.
+ </para>
+ <para>
You may add <link linkend="reference.pcre.pattern.modifiers">pattern
modifiers</link> after the ending delimiter. The following is an example
of case-insensitive matching: