toString()  RegExp  instance method JS Home  <<  JS Reference  <<  RegExp  <<  toString()

Description

Returns a string composed of concatenated array elements delimited by commas.

This method overrides the toString() method of Object.

Syntax

Signature Description
aRegExp.toString()Returns a string representation of the function.

Parameters

None.

Examples

The code below displays the toString() method on some RegExp instances.


var aRegExp = /\d/;
var bRegExp = /[^A-Za-z0-9_]/;
var regexpValues = new Array(2);

regexpValues[0] = 'aRegExp source: ' + aRegExp.toString() + '\n';
regexpValues[1] = 'bRegExp source: ' + bRegExp.toString();

alert(regexpValues);

Press the button below to action the above code:

Related Tutorials

JavaScript Intermediate Tutorials - Lesson 9 - Regular Expressions

JavaScript Basics

JavaScript Basics

JavaScript Intermediate

JavaScript Intermediate

JavaScript Advanced

JavaScript Advanced

JavaScript Reference

JavaScript Entities

Globals

RegExp

Class Properties
prototype
Instance Properties
constructor
global
ignoreCase
lastIndex
multiline
source
Class Methods
None.
Instance Methods Getters
exec()
test()
toString()
Instance Methods Setters
None.

Statements

Operators