In Julia, the match()
function returns only the first match of the regular expression, which is why match(r"\d+", "10, 11, 12")
gives "10"
and stops there. This is intended behavior and differs from eachmatch()
, which returns all matches in the string. The captures
field is empty because your pattern r"\d+"
doesn't include any capture groups—capture groups are defined using parentheses, like r"(\d+)"
. Without parentheses, there’s nothing to capture beyond the full match itself, which is accessible via m.match
. To retrieve all numbers from the string, eachmatch(r"\d+", ...)
is the correct approach.