svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml

From: Date: Sat, 19 Dec 2009 21:10:22 +0000
Subject: svn: /phpdoc/en/trunk/reference/pcre/ pattern.syntax.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-5691@lists.php.net to get a copy of this message
degeberg Sat, 19 Dec 2009 21:10:22 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=292344 Log: Closes #50232. Bug: http://bugs.php.net/50232 (Open) preg_replace - pattern description omits mention of string delimiter 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 2009-12-19 20:47:36 UTC (rev 292343) +++ phpdoc/en/trunk/reference/pcre/pattern.syntax.xml 2009-12-19 21:10:22 UTC (rev 292344) @@ -26,6 +26,62 @@ itself. </para> </section> + <section xml:id="regexp.reference.delimiters"> + <title>Delimiters</title> + <para> + When using the PCRE functions, it is required that the pattern is enclosed + in <emphasis>delimiters</emphasis>. A delimiter can be any non-alphanumeric, + non-whitespace character. + </para> + <para> + Often used delimiters are forward slashes (<literal>/</literal>), hash + signs (<literal>#</literal>) and tildes (<literal>~</literal>). The + following are all examples of valid delimited patterns. + <informalexample> + <programlisting> + /foo bar/ + #^[^0-9]$# + +php+ + %[a-zA-Z0-9_-]% + </programlisting> + </informalexample> + </para> + <para> + If the delimiter needs to be matched inside the pattern it will have to be + escaped using a backslash. If the delimiter appears often inside the + pattern, it is a good idea choosing another delimiter to increase + readability. + <informalexample> + <programlisting> + /http:\/\// + #http://# + </programlisting> + </informalexample> + The <function>preg_quote</function> may be used to inject a string into + a pattern and its second parameter allows to specify the chosen delimiter + so it will be escaped as well. + </para> + <para> + In addition to the aforementioned delimiters, it is also possible using + bracket style delimiters where the opening and closing brackets are the + starting and ending delimiter, respectively. + <informalexample> + <programlisting> + {this is a pattern} + </programlisting> + </informalexample> + </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: + <informalexample> + <programlisting> + #[a-z]#i + </programlisting> + </informalexample> + </para> + </section> <section xml:id="regexp.reference.meta"> <title>Meta-characters</title> <para>

« previous php.doc.cvs (#5691) next »