Standard built-ins
RegExp.prototype.exec()
Returns a match array with whole match, captures, index, input and optional groups/indices, or null. Built-in global or sticky matching updates lastIndex.
Formal Syntax & Structure
javascript syntaxjavascript
regex.exec(input)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| input | String | Text to match. |
Return Value
Array | null
Match record or null.
Working Example
Example Snippetjavascript
console.log(/\d+/.exec("a42")[0]);