Преглед изворни кода

[ZF-8415] Zend_Filter:

- added chapter for Zend_Filter_PregReplace

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19380 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas пре 16 година
родитељ
комит
375d790aa5

+ 53 - 0
documentation/manual/en/module_specs/Zend_Filter-PregReplace.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Reviewed: no -->
+<sect2 id="zend.filter.set.pregreplace">
+    <title>PregReplace</title>
+
+    <para>
+        <classname>Zend_Filter_PregReplace</classname> performs a search using regular expressions
+        and replaces all found elements.
+    </para>
+
+    <para>
+        The option <property>match</property> has to be given to set the pattern which will be
+        searched for. It can be a string for a single pattern, or an array of strings for multiple
+        pattern.
+    </para>
+
+    <para>
+        To set the pattern which will be used as replacement the option <property>replace</property>
+        has to be used. It can be a string for a single pattern, or an array of strings for multiple
+        pattern.
+    </para>
+
+    <programlisting language="php"><![CDATA[
+$filter = new Zend_Filter_PregReplace(array('match' => 'bob', 'replace' => 'john'));
+$input  = 'Hy bob!";
+
+$filter->filter($input);
+// returns 'Hy john!'
+]]></programlisting>
+
+    <para>
+        You can use <methodname>getMatchPattern()</methodname> and
+        <methodname>setMatchPattern()</methodname> to set the matching pattern afterwards. To set
+        the replacement pattern you can use <methodname>getReplacement()</methodname> and
+        <methodname>setReplacement()</methodname>.
+    </para>
+
+    <programlisting language="php"><![CDATA[
+$filter = new Zend_Filter_PregReplace();
+$filter->setMatchPattern(array('bob', 'Hy'))
+       ->setReplacement(array('john', 'Bye'));
+$input  = 'Hy bob!";
+
+$filter->filter($input);
+// returns 'Bye john!'
+]]></programlisting>
+
+    <para>
+        For a more complex usage take a look into <acronym>PHP</acronym>'s <ulink
+            linkend="http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php">PCRE
+            Pattern Chapter</ulink>.
+    </para>
+</sect2>

+ 8 - 8
documentation/manual/en/module_specs/Zend_Filter-Set.xml

@@ -80,14 +80,7 @@
     <xi:include href="Zend_Filter-LocalizedToNormalized.xml" />
     <xi:include href="Zend_Filter-NormalizedToLocalized.xml" />
     <xi:include href="Zend_Filter-Null.xml" />
-
-    <sect2 id="zend.filter.set.stripnewlines">
-        <title>StripNewlines</title>
-        <para>
-            Returns the string <varname>$value</varname> without any newline control characters.
-        </para>
-    </sect2>
-
+    <xi:include href="Zend_Filter-PregReplace.xml" />
     <xi:include href="Zend_Filter-RealPath.xml" />
     <xi:include href="Zend_Filter-StringToLower.xml" />
     <xi:include href="Zend_Filter-StringToUpper.xml" />
@@ -100,6 +93,13 @@
         </para>
     </sect2>
 
+    <sect2 id="zend.filter.set.stripnewlines">
+        <title>StripNewlines</title>
+        <para>
+            Returns the string <varname>$value</varname> without any newline control characters.
+        </para>
+    </sect2>
+
     <sect2 id="zend.filter.set.striptags">
         <title>StripTags</title>
         <para>