X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript source Property

RegExp Object Reference JavaScript RegExp Object

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;

The result of res will be:

The text of the RegExp is: W3S

Try it yourself »


Definition and Usage

The source property returns the text of the RegExp pattern.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The source property is supported in all major browsers.


Syntax

RegExpObject.source

Return Value

Type Description
String The text of the RegExp pattern

Technical Details

JavaScript Version: 1.2


RegExp Object Reference JavaScript RegExp Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook