<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The RegexIterator class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="recursivetreeiterator.valid.html">RecursiveTreeIterator::valid</a></div> <div class="next" style="text-align: right; float: right;"><a href="regexiterator.accept.html">RegexIterator::accept</a></div> <div class="up"><a href="spl.iterators.html">Iterators</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.regexiterator" class="reference"> <h1 class="title">The RegexIterator class</h1> <div class="partintro"><p class="verinfo">(PHP 5 >= 5.2.0)</p> <div class="section" id="regexiterator.intro"> <h2 class="title">Introduction</h2> <p class="para"> This iterator can be used to filter another iterator based on a regular expression. </p> </div> <div class="section" id="regexiterator.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">RegexIterator</strong> </span> <span class="ooclass"> <span class="modifier">extends</span> <a href="class.filteriterator.html" class="classname">FilterIterator</a> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.match"><var class="varname">MATCH</var></a></var> <span class="initializer"> = 0</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.get-match"><var class="varname">GET_MATCH</var></a></var> <span class="initializer"> = 1</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.all-matches"><var class="varname">ALL_MATCHES</var></a></var> <span class="initializer"> = 2</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.split"><var class="varname">SPLIT</var></a></var> <span class="initializer"> = 3</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.replace"><var class="varname">REPLACE</var></a></var> <span class="initializer"> = 4</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.regexiterator.html#regexiterator.constants.use-key"><var class="varname">USE_KEY</var></a></var> <span class="initializer"> = 1</span> ;</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="constructorsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="regexiterator.construct.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type"><a href="class.iterator.html" class="type Iterator">Iterator</a></span> <code class="parameter">$iterator</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = self::MATCH</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$preg_flags</code><span class="initializer"> = 0</span></span> ]]] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="regexiterator.accept.html" class="methodname">accept</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="regexiterator.getflags.html" class="methodname">getFlags</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="regexiterator.getmode.html" class="methodname">getMode</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="regexiterator.getpregflags.html" class="methodname">getPregFlags</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="regexiterator.getregex.html" class="methodname">getRegex</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="regexiterator.setflags.html" class="methodname">setFlags</a></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="regexiterator.setmode.html" class="methodname">setMode</a></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="regexiterator.setpregflags.html" class="methodname">setPregFlags</a></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$preg_flags</code></span> )</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Inherited methods */</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">abstract</span> <span class="type">bool</span> <span class="methodname"><a href="filteriterator.accept.html" class="methodname">FilterIterator::accept</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="filteriterator.construct.html" class="methodname">FilterIterator::__construct</a></span> ( <span class="methodparam"><span class="type"><a href="class.iterator.html" class="type Iterator">Iterator</a></span> <code class="parameter">$iterator</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="filteriterator.current.html" class="methodname">FilterIterator::current</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">Iterator</span> <span class="methodname"><a href="filteriterator.getinneriterator.html" class="methodname">FilterIterator::getInnerIterator</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">mixed</span> <span class="methodname"><a href="filteriterator.key.html" class="methodname">FilterIterator::key</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="filteriterator.next.html" class="methodname">FilterIterator::next</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="filteriterator.rewind.html" class="methodname">FilterIterator::rewind</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="filteriterator.valid.html" class="methodname">FilterIterator::valid</a></span> ( <span class="methodparam">void</span> )</div> }</div> </div> <div class="section" id="regexiterator.constants"> <h2 class="title">Predefined Constants</h2> <div class="section" id="regexiterator.constants.operation-modes"> <h2 class="title">RegexIterator operation modes</h2> <dl> <dt id="regexiterator.constants.all-matches"> <span class="term"><strong><code>RegexIterator::ALL_MATCHES</code></strong></span> <dd> <p class="para"> Return all matches for the current entry (see <span class="function"><a href="function.preg-match-all.html" class="function">preg_match_all()</a></span>). </p> </dd> </dt> <dt id="regexiterator.constants.get-match"> <span class="term"><strong><code>RegexIterator::GET_MATCH</code></strong></span> <dd> <p class="para"> Return the first match for the current entry (see <span class="function"><a href="function.preg-match.html" class="function">preg_match()</a></span>). </p> </dd> </dt> <dt id="regexiterator.constants.match"> <span class="term"><strong><code>RegexIterator::MATCH</code></strong></span> <dd> <p class="para"> Only execute match (filter) for the current entry (see <span class="function"><a href="function.preg-match.html" class="function">preg_match()</a></span>). </p> </dd> </dt> <dt id="regexiterator.constants.replace"> <span class="term"><strong><code>RegexIterator::REPLACE</code></strong></span> <dd> <p class="para"> Replace the current entry (see <span class="function"><a href="function.preg-replace.html" class="function">preg_replace()</a></span>; Not fully implemented yet) </p> </dd> </dt> <dt id="regexiterator.constants.split"> <span class="term"><strong><code>RegexIterator::SPLIT</code></strong></span> <dd> <p class="para"> Returns the split values for the current entry (see <span class="function"><a href="function.preg-split.html" class="function">preg_split()</a></span>). </p> </dd> </dt> </dl> </div> <div class="section" id="regexiterator.constants.flags"> <h2 class="title">RegexIterator Flags</h2> <dl> <dt id="regexiterator.constants.use-key"> <span class="term"><strong><code>RegexIterator::USE_KEY</code></strong></span> <dd> <p class="para"> Special flag: Match the entry key instead of the entry value. </p> </dd> </dt> </dl> </div> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="regexiterator.accept.html">RegexIterator::accept</a> — Get accept status</li><li><a href="regexiterator.construct.html">RegexIterator::__construct</a> — Create a new RegexIterator</li><li><a href="regexiterator.getflags.html">RegexIterator::getFlags</a> — Get flags</li><li><a href="regexiterator.getmode.html">RegexIterator::getMode</a> — Returns operation mode.</li><li><a href="regexiterator.getpregflags.html">RegexIterator::getPregFlags</a> — Returns the regular expression flags.</li><li><a href="regexiterator.getregex.html">RegexIterator::getRegex</a> — Returns current regular expression</li><li><a href="regexiterator.setflags.html">RegexIterator::setFlags</a> — Sets the flags.</li><li><a href="regexiterator.setmode.html">RegexIterator::setMode</a> — Sets the operation mode.</li><li><a href="regexiterator.setpregflags.html">RegexIterator::setPregFlags</a> — Sets the regular expression flags.</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="recursivetreeiterator.valid.html">RecursiveTreeIterator::valid</a></div> <div class="next" style="text-align: right; float: right;"><a href="regexiterator.accept.html">RegexIterator::accept</a></div> <div class="up"><a href="spl.iterators.html">Iterators</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>