<!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>Regular expression match with multibyte support</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-ereg-search.html">mb_ereg_search</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-eregi-replace.html">mb_eregi_replace</a></div> <div class="up"><a href="ref.mbstring.html">Multibyte String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.mb-ereg" class="refentry"> <div class="refnamediv"> <h1 class="refname">mb_ereg</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mb_ereg</span> — <span class="dc-title">Regular expression match with multibyte support</span></p> </div> <div class="refsect1 description" id="refsect1-function.mb-ereg-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>mb_ereg</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$regs</code></span> ] )</div> <p class="simpara"> Executes the regular expression match with multibyte support. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mb-ereg-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter">pattern</code></dt> <dd> <p class="para"> The search pattern. </p> </dd> <dt> <code class="parameter">string</code></dt> <dd> <p class="para"> The search <span class="type"><a href="language.types.string.html" class="type string">string</a></span>. </p> </dd> <dt> <code class="parameter">regs</code></dt> <dd> <p class="para"> If matches are found for parenthesized substrings of <code class="parameter">pattern</code> and the function is called with the third argument <code class="parameter">regs</code>, the matches will be stored in the elements of the array <code class="parameter">regs</code>. If no matches are found, <code class="parameter">regs</code> is set to an empty array. </p> <p class="para"> <var class="varname"><var class="varname">$regs[1]</var></var> will contain the substring which starts at the first left parenthesis; <var class="varname"><var class="varname">$regs[2]</var></var> will contain the substring starting at the second, and so on. <var class="varname"><var class="varname">$regs[0]</var></var> will contain a copy of the complete string matched. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.mb-ereg-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the byte length of the matched string if a match for <code class="parameter">pattern</code> was found in <code class="parameter">string</code>, or <strong><code>FALSE</code></strong> if no matches were found or an error occurred. </p> <p class="para"> If the optional parameter <code class="parameter">regs</code> was not passed or the length of the matched string is <em>0</em>, this function returns <em>1</em>. </p> </div> <div class="refsect1 changelog" id="refsect1-function.mb-ereg-changelog"> <h3 class="title">Changelog</h3> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>7.1.0</td> <td> <span class="function"><strong>mb_ereg()</strong></span> will now set <code class="parameter">regs</code> to an empty <span class="type"><a href="language.types.array.html" class="type array">array</a></span>, if nothing matched. Formerly, <code class="parameter">regs</code> was not modified in that case. </td> </tr> </tbody> </table> </div> <div class="refsect1 notes" id="refsect1-function.mb-ereg-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">The internal encoding or the character encoding specified by <span class="function"><a href="function.mb-regex-encoding.html" class="function">mb_regex_encoding()</a></span> will be used as the character encoding for this function.</p></p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.mb-ereg-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.mb-regex-encoding.html" class="function" rel="rdfs-seeAlso">mb_regex_encoding()</a> - Set/Get character encoding for multibyte regex</span></li> <li class="member"><span class="function"><a href="function.mb-eregi.html" class="function" rel="rdfs-seeAlso">mb_eregi()</a> - Regular expression match ignoring case with multibyte support</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-ereg-search.html">mb_ereg_search</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-eregi-replace.html">mb_eregi_replace</a></div> <div class="up"><a href="ref.mbstring.html">Multibyte String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>