Standard built-ins

String.prototype.match()

Try the free JavaScript compiler

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

NameTypeDescription
regexpRegExp | StringPattern or convertible pattern.

Return Value

Array | null

Matches or null.

Working Example

Example Snippetjavascript
console.log(JSON.stringify("a1 b2".match(/\d/g)));
JavaScript Reference