On this page
  1. String.matchAll
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

String.matchAll

Prev: trim | Up: String | Next: substr
Rel: String, String, RegExp & Intl Guide
Ref: MDN Web Docs — String.matchAll
Tags: #public #web #javascript #builtins #string #tier/standard


Signature & Overview

str.matchAll(regexp)

Returns a lazy iterator of all regex match objects including capture groups and indices.

Notes & Pitfalls

Example

const matches = [..."a=1 b=2".matchAll(/(?<k>\w+)=(?<v>\d+)/g)];
console.assert(matches.length === 2 && matches[1].groups.k === "b");

Linked from

Related notes