--- 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 ---
標準外の input プロパティは正規表現の一致している文字列を含む静的プロパティです。 RegExp.$_ はこのプロパティのエイリアスです。
input プロパティは静的プロパティです。個々の正規表現オブジェクトのプロパティではありません。常に、 RegExp.input または RegExp.$_. として使用してください。
input プロパティの値は、正規表現の検索文字列が変更され文字列が一致しているときはいつでも変更されます。
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!"
| 仕様書 |
|---|
| {{SpecName('Legacy RegExp features')}} |
{{Compat("javascript.builtins.RegExp.lastMatch")}}