We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

toString Redirect 2


The toString() method returns a string representing the regular expression.






The RegExp object overrides the toString method of the Object object; it does not inherit Object.prototype.toString(). For RegExp objects, the toString method returns a string representation of the regular expression.


Example: Using toString

The following example displays the string value of a RegExp object:

myExp = new RegExp("a+b+c");
alert(myExp.toString());       // displays "/a+b+c/"

foo = new RegExp("bar", "g");
alert(foo.toString());         // displays "/bar/g"


Specification Status Comment
ECMAScript 3rd Edition. Implemented in JavaScript 1.1 Standard Initial definition.
ECMAScript Language Specification 5.1th Edition (ECMA-262) Standard  
ECMAScript Language Specification 6th Edition (ECMA-262) Draft  

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

 Last updated by: Sheppy,