The source property returns a String containing the text of the pattern, excluding the forward slashes. It is a read-only property of an individual regular expression instance. source does not contain any flags (like "g", "i" or "m") of the regular expression.
Property attributes of RegExp.prototype.source
Writable
No
Enumerable
No
Configurable
No
Examples
Example: Using source
var regex = new RegExp("fooBar", "g")
console.log(regex.source) // "fooBar"
Specifications
Specification
Status
Comment
ECMAScript 3rd Edition. Implemented in JavaScript 1.2.
Standard
Initial definition.
JavaScript 1.5: source is a property of a RegExp instance, not the RegExp object.