RegExp.exec

exec — Executes the regular expression on a string.

Description

RegExp.exec(string string)

Parameters

Name Description Type Default Optional
string string No

Return values

mixed: Array or null if no match.

Examples

Example #1 – exec example
console.log(/[a-z]+/.exec('Hello World')); // ["ello", index: 1, input: "Hello World"] console.log(/[a-z]+/.exec('FOO')); // null

External references