JavaScript source Property
Example
let text = "Visit W3Schools";
let pattern = /W3S/g;
let result = pattern.source;
Try it Yourself »
Description
The source property returns the text of the RegExp pattern.
Browser Support
source
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
RegExpObject.source
Return Value
Type | Description |
---|---|
String | The text of the RegExp pattern |