Skip to content

Regex Match All

The regex::matchall function returns all substrings in a string that match a given regular expression pattern.

Syntax

regex::matchall(<pattern>, <string>)

Parameters

  • pattern: The regular expression pattern to match against.
  • string: The input string to search.

Returns

  • List: A list of all substrings that match the pattern.

Example

Try it out below!
regex::matchall("\\b\\w{4}\\b", "This is a test")

This function is useful for extracting all occurrences of a pattern from a string.