JavaScript source Property
Example
Return the text of the RegExp pattern:
var str = "Visit W3Schools";
var patt1 = /W3S/g;
var res = "The text of the RegExp is: " + patt1.source;
Try it Yourself »
Definition and Usage
The source property returns the text of the RegExp pattern.
Browser Support
Property | |||||
---|---|---|---|---|---|
source | Yes | Yes | Yes | Yes | Yes |
Syntax
RegExpObject.source
Return Value
Type | Description |
---|---|
String | The text of the RegExp pattern |
Technical Details
JavaScript Version: | ECMAScript 1 |
---|
❮ JavaScript RegExp Object