<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.regexiterator.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'regexiterator.construct.php',
    1 => 'RegexIterator::__construct',
    2 => 'Create a new RegexIterator',
  ),
  'up' => 
  array (
    0 => 'class.regexiterator.php',
    1 => 'RegexIterator',
  ),
  'prev' => 
  array (
    0 => 'regexiterator.accept.php',
    1 => 'RegexIterator::accept',
  ),
  'next' => 
  array (
    0 => 'regexiterator.getflags.php',
    1 => 'RegexIterator::getFlags',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/spl/regexiterator/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="regexiterator.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RegexIterator::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">RegexIterator::__construct</span> &mdash; <span class="dc-title">Create a new RegexIterator</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-regexiterator.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>RegexIterator::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.iterator.php" class="type Iterator">Iterator</a></span> <code class="parameter">$iterator</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pattern</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="class.regexiterator.php#regexiterator.constants.match">RegexIterator::MATCH</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$pregFlags</code><span class="initializer"> = 0</span></span><br>)</div>


  <p class="para rdfs-comment">
   Create a new <span class="classname"><a href="class.regexiterator.php" class="classname">RegexIterator</a></span> which filters an
   <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span> using a regular expression.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-regexiterator.construct-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">iterator</code></dt>
     <dd>
      <p class="para">
       The iterator to apply this regex filter to.
      </p>
     </dd>
    
    
     <dt><code class="parameter">pattern</code></dt>
     <dd>
      <p class="para">
       The regular expression to match.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Operation mode, see <span class="methodname"><a href="regexiterator.setmode.php" class="methodname">RegexIterator::setMode()</a></span> for a list
       of modes.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Special flags, see <span class="methodname"><a href="regexiterator.setflags.php" class="methodname">RegexIterator::setFlags()</a></span> for a list
       of available flags.
      </p>
     </dd>
    
    
     <dt><code class="parameter">pregFlags</code></dt>
     <dd>
      <p class="para">
       The regular expression flags. These flags depend on the operation mode parameter:
      </p>
      <p class="para">
      <table class="doctable table">
        <caption><strong><span class="classname"><a href="class.regexiterator.php" class="classname">RegexIterator</a></span> preg_flags</strong></caption>
        
         <thead>
          <tr>
           <th>operation mode</th>
           <th>available flags</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><var class="varname">RegexIterator::ALL_MATCHES</var></td>
           <td>
            See <span class="function"><a href="function.preg-match-all.php" class="function">preg_match_all()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname">RegexIterator::GET_MATCH</var></td>
           <td>
            See <span class="function"><a href="function.preg-match.php" class="function">preg_match()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname">RegexIterator::MATCH</var></td>
           <td>
            See <span class="function"><a href="function.preg-match.php" class="function">preg_match()</a></span>.
           </td>
          </tr>

          <tr>
           <td><var class="varname">RegexIterator::REPLACE</var></td>
           <td>
            none.
           </td>
          </tr>

          <tr>
           <td><var class="varname">RegexIterator::SPLIT</var></td>
           <td>
            See <span class="function"><a href="function.preg-split.php" class="function">preg_split()</a></span>.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 
<div class="refsect1 errors" id="refsect1-regexiterator.construct-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws an <span class="classname"><a href="class.invalidargumentexception.php" class="classname">InvalidArgumentException</a></span> if the <code class="parameter">pattern</code> argument is invalid.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-regexiterator.construct-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>RegexIterator::__construct()</strong></span> example</strong></p>
    <div class="example-contents"><p>
      Creates a new RegexIterator that filters all strings that start with &#039;test&#039;.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$arrayIterator </span><span style="color: #007700">= new </span><span style="color: #0000BB">ArrayIterator</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'test 1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'another test'</span><span style="color: #007700">, </span><span style="color: #DD0000">'test 123'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$regexIterator </span><span style="color: #007700">= new </span><span style="color: #0000BB">RegexIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$arrayIterator</span><span style="color: #007700">, </span><span style="color: #DD0000">'/^test/'</span><span style="color: #007700">);<br /><br />foreach (</span><span style="color: #0000BB">$regexIterator </span><span style="color: #007700">as </span><span style="color: #0000BB">$value</span><span style="color: #007700">) {<br />    echo </span><span style="color: #0000BB">$value </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">test 1
test 123</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-regexiterator.construct-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.preg-match.php" class="function" rel="rdfs-seeAlso">preg_match()</a> - Perform a regular expression match</span></li>
    <li><span class="function"><a href="function.preg-match-all.php" class="function" rel="rdfs-seeAlso">preg_match_all()</a> - Perform a global regular expression match</span></li>
    <li><span class="function"><a href="function.preg-replace.php" class="function" rel="rdfs-seeAlso">preg_replace()</a> - Perform a regular expression search and replace</span></li>
    <li><span class="function"><a href="function.preg-split.php" class="function" rel="rdfs-seeAlso">preg_split()</a> - Split string by a regular expression</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>