---
title: RegExp.input ($_)
slug: Web/JavaScript/Reference/Global_Objects/RegExp/input
tags:
  - JavaScript
  - Non-standard
  - Property
  - Reference
  - RegExp
  - Regular Expressions
translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/input
---
<div>{{JSRef}} {{non-standard_header}}</div>

<p>標準外の <strong><code>input</code></strong> プロパティは正規表現の一致している文字列を含む静的プロパティです。 <code>RegExp.$_</code> はこのプロパティのエイリアスです。</p>

<h2 id="Description" name="Description">解説</h2>

<p><code>input</code> プロパティは静的プロパティです。個々の正規表現オブジェクトのプロパティではありません。常に、 <code>RegExp.input</code> または <code>RegExp.$_.</code> として使用してください。</p>

<p><code><strong>input</strong></code> プロパティの値は、正規表現の検索文字列が変更され文字列が一致しているときはいつでも変更されます。</p>

<h2 id="Examples">Examples</h2>

<h3 id="Using_lastIndex" name="Using_lastIndex">input と $_ の使用</h3>

<pre class="brush: js notranslate">var re = /hi/g;
re.test('hi there!');
RegExp.input;         // "hi there!"
re.test('foo');       // new test, non-matching
RegExp.$_;            // "hi there!"
re.test('hi world!'); // new test, matching
RegExp.$_;            // "hi world!"
</pre>

<h2 id="Specifications" name="Specifications">仕様書</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">仕様書</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('Legacy RegExp features')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>

<div>
<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>

<p>{{Compat("javascript.builtins.RegExp.lastMatch")}}</p>
</div>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{jsxref("RegExp.lastMatch", "RegExp.lastMatch ($&amp;)")}}</li>
 <li>{{jsxref("RegExp.lastParen", "RegExp.lastParen ($+)")}}</li>
 <li>{{jsxref("RegExp.leftContext", "RegExp.leftContext ($`)")}}</li>
 <li>{{jsxref("RegExp.rightContext", "RegExp.rightContext ($')")}}</li>
 <li>{{jsxref("RegExp.n", "RegExp.$1-$9")}}</li>
</ul>