RegExp source
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.
Syntax
 RegExpObject.source
Return Value
| Type | Description | 
|---|---|
| String | The text of the RegExp pattern | 
Browser Support
regexp.source is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | 
 
