We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS



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 source
Writable no
Enumerable no
Configurable no


Example: Using source

var regex = new RegExp("fooBar", "g")

console.log(regex.source) // "fooBar"


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.
ECMAScript Language Specification 5.1th Edition (ECMA-262) Standard  
ECMAScript Language Specification 6th Edition (ECMA-262) Draft source is now a prototype accessor property rather than an instance's own data property.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also

Document Tags and Contributors

Contributors to this page: Sevenspade
Last updated by: Sevenspade,