RegExp.prototype.exec

Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.

Syntax

exec(string)

Parameters

Return value

An array containing the entire match result and any parentheses-captured matched results; null if no match is found.

The array has extra properties:

Examples

/[a-z]/.exec('abc')
["a"]
/(?[\d-]+)/.exec('mobile: 123-45-67').groups.phone
"123-45-67"