83
JavaScript RegExp.prototype.exec() Method
The exec() method returns an array containing all the matched groups. It executes a search for a match in a specified string. If it finds a match, it returns an array. Otherwise, it returns null.
Syntax
Parameters
string : The string to be searched.
Return value
It will return the array if a match is found. Otherwise, it will return null.
Example 1
Output:
Test 1 - returned value : script
Example 2
Output:
Test 2 - returned value : null
Example 3
Output:
Returned value : script Returned value : language
Next TopicJavaScript RegExp