<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mbstring.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.mb-regex-set-options.php',
    1 => 'mb_regex_set_options',
    2 => 'マルチバイト正規表現関数のデフォルトオプションを取得または設定する',
  ),
  'up' => 
  array (
    0 => 'ref.mbstring.php',
    1 => 'マルチバイト文字列 関数',
  ),
  'prev' => 
  array (
    0 => 'function.mb-regex-encoding.php',
    1 => 'mb_regex_encoding',
  ),
  'next' => 
  array (
    0 => 'function.mb-rtrim.php',
    1 => 'mb_rtrim',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/mbstring/functions/mb-regex-set-options.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mb-regex-set-options" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_regex_set_options</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mb_regex_set_options</span> &mdash; <span class="dc-title">マルチバイト正規表現関数のデフォルトオプションを取得または設定する</span></p>

 </div>
   
 <div class="refsect1 description" id="refsect1-function.mb-regex-set-options-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_regex_set_options</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   <code class="parameter">options</code> で表されるオプションを、
   マルチバイト対応の正規表現関数のデフォルトに設定します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-regex-set-options-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       設定するオプション。文字列で設定し、各文字がオプションを表します。
       モードを設定する際には、モード文字は最後に指定しなければなりません。
       オプションは複数指定できますが、モードはひとつしか指定できません。
      </p>

      <table class="doctable table">
       <caption><strong>Regex のオプション</strong></caption>
       
        <thead>
         <tr>
          <th>オプション</th>
          <th>意味</th>
          <th>変更履歴</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>i</td>
          <td>曖昧なマッチをオンにする</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>x</td>
          <td>拡張パターン形式を有効にする</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>m</td>
          <td><code class="literal">&#039;.&#039;</code> が改行にマッチする</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>s</td>
          <td><code class="literal">&#039;^&#039;</code> -&gt; <code class="literal">&#039;\A&#039;</code>, <code class="literal">&#039;$&#039;</code> -&gt; <code class="literal">&#039;\Z&#039;</code></td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>p</td>
          <td><code class="literal">m</code> と <code class="literal">s</code> を両方指定するのと同じ</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>l</td>
          <td>最も長くマッチするものを探す</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>n</td>
          <td>空のマッチを無視する</td>
          <td class="empty">&nbsp;</td>
         </tr>

         <tr>
          <td>e</td>
          <td>結果のコードを <span class="function"><a href="function.eval.php" class="function">eval()</a></span> する</td>
          <td>PHP 7.1.0 で非推奨になり、PHP 8.0.0 で削除されました。</td>
         </tr>

        </tbody>
       
      </table>

      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        <span class="function"><strong>mb_regex_set_options()</strong></span> に <code class="literal">&quot;e&quot;</code>
        オプションを設定しても、何も起きません。
        <span class="function"><a href="function.mb-ereg-replace.php" class="function">mb_ereg_replace()</a></span> や <span class="function"><a href="function.mb-eregi-replace.php" class="function">mb_eregi_replace()</a></span> で指定するようにしてください。
       </p>
      </p></blockquote>
      <table class="doctable table">
       <caption><strong>Regex 構文モード(ひとつだけ設定可能です)</strong></caption>
       
        <thead>
         <tr>
          <th>モード</th>
          <th>意味</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>j</td>
          <td>Java (Sun java.util.regex)</td>
         </tr>

         <tr>
          <td>u</td>
          <td>GNU regex</td>
         </tr>

         <tr>
          <td>g</td>
          <td>grep</td>
         </tr>

         <tr>
          <td>c</td>
          <td>Emacs</td>
         </tr>

         <tr>
          <td>r</td>
          <td>Ruby</td>
         </tr>

         <tr>
          <td>z</td>
          <td>Perl</td>
         </tr>

         <tr>
          <td>b</td>
          <td>POSIX Basic regex</td>
         </tr>

         <tr>
          <td>d</td>
          <td>POSIX Extended regex</td>
         </tr>

        </tbody>
       
      </table>

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


 <div class="refsect1 returnvalues" id="refsect1-function.mb-regex-set-options-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   以前設定されていたオプションを返します。
   <code class="parameter">options</code> が省略された場合、または <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> の場合、
   現在設定されているオプションを文字列で返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mb-regex-set-options-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">options</code> が指定され、<strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> でない場合、
       <em>以前に</em> 設定されていたオプションが返されるようになりました。
       これより前のバージョンでは、
       <em>現在</em> 設定されているオプションが返されていました。
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">options</code> は、nullable になりました。
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="literal">&quot;e&quot;</code> オプションを指定すると、<span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> がスローされるようになりました。
      </td>
     </tr>

     <tr>
      <td>7.1.0</td>
      <td>
       <code class="literal">&quot;e&quot;</code> オプションを指定すると、<strong><code><a href="errorfunc.constants.php#constant.e-deprecated">E_DEPRECATED</a></code></strong> が発生するようになりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-regex-set-options-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.mb-split.php" class="function" rel="rdfs-seeAlso">mb_split()</a> - マルチバイト文字列を正規表現により分割する</span></li>
    <li><span class="function"><a href="function.mb-ereg.php" class="function" rel="rdfs-seeAlso">mb_ereg()</a> - マルチバイト対応の正規表現マッチ</span></li>
    <li><span class="function"><a href="function.mb-eregi.php" class="function" rel="rdfs-seeAlso">mb_eregi()</a> - マルチバイトをサポートし、大文字小文字を無視した正規表現マッチ</span></li>
   </ul>
  </p>
 </div>


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