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 (JavaScript 1997) feature.
It is 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 |