JavaScriptソースプロパティ
例
let text = "Visit W3Schools";
let pattern = /W3S/g;
let result = pattern.source;
定義と使用法
sourceプロパティは、RegExpパターンのテキストを返します。
ブラウザのサポート
source
ECMAScript1(ES1)機能です。
ES1(JavaScript 1997)は、すべてのブラウザーで完全にサポートされています。
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
構文
RegExpObject.source
戻り値
Type | Description |
---|---|
String | The text of the RegExp pattern |