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.

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

Test it Now

Output:

Test 1 - returned value : script

Example 2

Test it Now

Output:

Test 2 - returned value : null

Example 3

Test it Now

Output:

Returned value : script
Returned value : language
Next TopicJavaScript RegExp





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA