Javatpoint Logo
Javatpoint Logo

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.



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

Test it Now


Test 1 - returned value : script

Example 2

Test it Now


Test 2 - returned value : null

Example 3

Test it Now


Returned value : script
Returned value : language
Next TopicJavaScript RegExp

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA