Skip to content
Regular expressionsReference

Regex:MatchMany

Collect all non-overlapping matches.

Details#

Collect all non-overlapping matches. A 1-based array of full matches; an empty array when none match. Capture groups are not separate results. Evaluation failure raises an error.

Signature#

Luau
regex:MatchMany(text: string): {string}

Parameters#

ParameterTypeDescription
textstringText searched by the compiled expression.

Returns#

A 1-based array of full matches; an empty array when none match. Capture groups are not separate results. Evaluation failure raises an error.

Examples#

Local example

Luau
local values = Regex.new("[0-9]+"):MatchMany("a12 b34")
print(values[1], values[2]) -- 12 34