Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

RegExp.lastParen ($+)

この記事は編集レビューを必要としています。ぜひご協力ください

この翻訳は不完全です。英語から この記事を翻訳 してください。

非標準
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

概要

非標準のlastParen プロパティは最後の括弧で囲まれた部分文字列の一致を含む正規表現の静的で読み取り専用プロパティです。RegExp.$+はこのプロパティに対するエイリアスです。

構文

RegExp.lastParen
RegExp['$+']

説明

lastParen プロパティは静的プロパティです。個々の正規表現オブジェクトのプロパティではありません。そのかわりに、常に、RegExp.lastParenまたはRegExp['$+'].として使用してください。

lastParenプロパティの値は、読み取り専用で、一致に成功したときはいつでも変更されます。

ドットプロパティアクセス(RegExp.$+)の速記のエイリアスを使用しないでください。というのも、パーサはその場合に"+"の表現を期待し、SyntaxErrorがスローされるからです。 プロパティへのアクセスにブラケット表記法を使用してください。

例: lastParen$+を使う

var re = /(hi)/g;
re.test("hi there!");
RegExp.lastParen; // "hi"
RegExp['$+'];     // "hi"

仕様

非標準。すべての現在の仕様でサポートされておりません。

ブラウザ実装状況

機能 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本サポート (有) (有) (有) (有) (有)
機能 Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基本サポート (有) (有) (有) (有) (有) (有)

関連情報

ドキュメントのタグと貢献者

 このページの貢献者: shide55
 最終更新者: shide55,