MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    source Redirect 1

    Summary

    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 Redirect 1
    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.
    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: Sheppy
    Last updated by: Sheppy,