Standard built-ins
String.prototype.match()
Delegates to a regex match operation. An ordinary global regex returns whole matches only; nonglobal returns capture information.
Formal Syntax & Structure
javascript syntaxjavascript
text.match(regexp)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| regexp | RegExp | String | Pattern or convertible pattern. |
Return Value
Array | null
Matches or null.
Working Example
Example Snippetjavascript
console.log(JSON.stringify("a1 b2".match(/\d/g)));