I have a str
value containing a fair amount of text, and I match it against a regex. The str
contains multiple matches of the regex, but of course I only get the first.
How can I enumerate over the other matches, of better, how can I collect them into a list[str]
?
Example:
str text = "hello here how home";
Now I can do:
if (/<match:h+>/ := text) println(match);
which prints the first match: hello
.
Now, instead, I'd love to collect all matches into a list[str]
. Other languages provide the g
flag for global matching. What's Rascal's idiom for this?