[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/_language-snippets.ent_reference/pcre/pattern.posix.xml_re
From:       Daniel_Egeberg <degeberg () php ! net>
Date:       2010-03-28 15:02:41
Message-ID: svn-degeberg-1269788561-296975-1244557623 () svn ! php ! net
[Download RAW message or body]

degeberg                                 Sun, 28 Mar 2010 15:02:41 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=296975

Log:
Added section that outlines notable differences between POSIX regex and PCRE regex.

Changed paths:
    U   phpdoc/en/trunk/language-snippets.ent
    A   phpdoc/en/trunk/reference/pcre/pattern.posix.xml
    U   phpdoc/en/trunk/reference/pcre/pattern.xml

Modified: phpdoc/en/trunk/language-snippets.ent
===================================================================
--- phpdoc/en/trunk/language-snippets.ent	2010-03-28 14:44:38 UTC (rev 296974)
+++ phpdoc/en/trunk/language-snippets.ent	2010-03-28 15:02:41 UTC (rev 296975)
@@ -10,7 +10,8 @@
 <!ENTITY note.regex.deprecated '<note xmlns="http://docbook.org/ns/docbook"><para>As \
of PHP 5.3.0, the  regex extension is deprecated in favor of the
 <link linkend="book.pcre">PCRE extension</link>. Calling this function
-will issue an <constant>E_DEPRECATED</constant> notice.</para></note>'>
+will issue an <constant>E_DEPRECATED</constant> notice. See <link \
linkend="reference.pcre.pattern.posix">the list of +differences</link> for help on \
converting to PCRE.</para></note>'>

 <!ENTITY note.bin-safe '<note xmlns="http://docbook.org/ns/docbook"><simpara>This \
function is  binary-safe.</simpara></note>'>

Added: phpdoc/en/trunk/reference/pcre/pattern.posix.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/pattern.posix.xml	                        (rev 0)
+++ phpdoc/en/trunk/reference/pcre/pattern.posix.xml	2010-03-28 15:02:41 UTC (rev \
296975) @@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision$ -->
+<article xml:id="reference.pcre.pattern.posix" \
xmlns="http://docbook.org/ns/docbook"> + <title>Differences from POSIX regex</title>
+
+ <para>
+  As of PHP 5.3.0, the <link linkend="book.regex">POSIX Regex</link> extension
+  is deprecated. There are a number of differences between POSIX regex and
+  PCRE regex. This page lists the most notable ones that are necessary to
+  know when converting to PCRE.
+ </para>
+
+ <para>
+  <orderedlist>
+   <listitem>
+    <simpara>
+     The PCRE functions require that the pattern is enclosed by <link
+     linkend="regexp.reference.delimiters">delimiters</link>.
+    </simpara>
+   </listitem>
+   <listitem>
+    <simpara>
+     Unlike POSIX, the PCRE extension does not have dedicated functions for
+     case-insensitive matching. Instead, this is supported using the /i <link
+     linkend="reference.pcre.pattern.modifiers">pattern modifier</link>. Other
+     pattern modifiers are also available for changing the matching strategy.
+    </simpara>
+   </listitem>
+   <listitem>
+    <simpara>
+     The POSIX functions find the longest of the leftmost match, but PCRE
+     stops on the first valid match. If the string doesn't match at all it
+     makes no difference, but if it matches it may have dramatic effects on
+     both the resulting match and the matching speed.
+    </simpara>
+    <simpara>
+     To illustrate this difference, consider the following example from
+     "Mastering Regular Expressions" by Jeffrey Friedl. Using the pattern
+     <literal>one(self)?(selfsufficient)?</literal> on the string
+     <literal>oneselfsufficient</literal> with PCRE will result in matching
+     <literal>oneself</literal>, but using POSIX the result will be the full
+     string <literal>oneselfsufficient</literal>. Both (sub)strings match the
+     original string, but POSIX requires that the longest be the result.
+    </simpara>
+   </listitem>
+  </orderedlist>
+ </para>
+
+ <para>
+  <table>
+   <title>Function replacements</title>
+   <tgroup cols="2">
+    <thead>
+     <row>
+      <entry>POSIX</entry>
+      <entry>PCRE</entry>
+     </row>
+    </thead>
+    <tbody>
+     <row>
+      <entry><function>ereg_replace</function></entry>
+      <entry><function>preg_replace</function></entry>
+     </row>
+     <row>
+      <entry><function>ereg</function></entry>
+      <entry><function>preg_match</function></entry>
+     </row>
+     <row>
+      <entry><function>eregi_repalce</function></entry>
+      <entry><function>preg_replace</function></entry>
+     </row>
+     <row>
+      <entry><function>eregi</function></entry>
+      <entry><function>preg_match</function></entry>
+     </row>
+     <row>
+      <entry><function>split</function></entry>
+      <entry><function>preg_split</function></entry>
+     </row>
+     <row>
+      <entry><function>spliti</function></entry>
+      <entry><function>preg_split</function></entry>
+     </row>
+     <row>
+      <entry><function>sql_regcase</function></entry>
+      <entry><emphasis>No equivalent</emphasis></entry>
+     </row>
+    </tbody>
+   </tgroup>
+  </table>
+ </para>
+</article>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:1
+sgml-indent-data:t
+indent-tabs-mode:nil
+sgml-parent-document:nil
+sgml-default-dtd-file:"~/.phpdoc/manual.ced"
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+vim600: syn=xml fen fdm=syntax fdl=2 si
+vim: et tw=78 syn=sgml
+vi: ts=1 sw=1
+-->

Modified: phpdoc/en/trunk/reference/pcre/pattern.xml
===================================================================
--- phpdoc/en/trunk/reference/pcre/pattern.xml	2010-03-28 14:44:38 UTC (rev 296974)
+++ phpdoc/en/trunk/reference/pcre/pattern.xml	2010-03-28 15:02:41 UTC (rev 296975)
@@ -6,6 +6,7 @@

  &reference.pcre.pattern.modifiers;
  &reference.pcre.pattern.differences;
+ &reference.pcre.pattern.posix;
  &reference.pcre.pattern.syntax;

 </part>



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic