JavaScript RegExp toString()
例1
正規表現の文字列値を返します。
let pattern = new RegExp("Hello World", "g");
let text = pattern.toString();
定義と使用法
toString()メソッドは、正規表現の文字列値を返します。
例2
正規表現の文字列値を返します。
let pattern = /Hello World/g;
let text = pattern.toString();
ブラウザのサポート
toString()
ECMAScript1(ES1)機能です。
ES1(JavaScript 1997)は、すべてのブラウザーで完全にサポートされています。
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
構文
RegExpObject.toString()
パラメーター
なし。 |
戻り値
Type | Description |
---|---|
String | The string value of the regular expression |