JavaScript provides an object named RegExp. You can create an instance by using new or the literal //.
The RegExp Object
I’ll start with an overview and follow it with several examples.
Methods
Apart from the RegExp object, you can use several built-in string functions in JavaScript to deal with regular expressions. The object knows these methods:
exec(): Executes the test and returns the first hit.
test(): Executes the test and returns either true or false.
toString(): Returns the expression as a string.
The exec method returns an object that has the following content:
An array with the groups (counting ...