extractAll
The extractAll() method returns an iterator of all match details found in a string for a given regular expression.
Interactive example
Syntax
Classic signature
typescript
function extractAll<
GenericInput extends string
>(
input: GenericInput,
pattern: RegExp
): Generator<ExtractResult>;Curried signature
typescript
function extractAll<
GenericInput extends string
>(
pattern: RegExp
): (input: GenericInput) => Generator<ExtractResult>;Parameters
input: The string to analyze.pattern: The regular expression to use to find matches. It must have theg(global) flag to find all matches.
Return value
An iterator (Generator<ExtractResult>) that lets you iterate over all matches found in the input string.
ExtractResult contains:
matchedValue: The full matched substring.groups: An array of captured groups (excluding the full match).namedGroups: A record of named groups if present.offset: The start index of the match.self: The original input string.
See also
- extract: Extracts details about the first match.
- match: Searches for a match with a regular expression.
- matchAll: Searches for all matches with a regular expression.
