Methods

~~ΒΆ

~~(s:Str, r:RegExp, collect_unmatched:Bool=false)

Find all non-overlapping matches of regular expression in a string.
Source: stdlib.ngs:3740

Returns

if collect_unmatched - Arr with each element being MatchY or Str, if not collect_unmatched - Arr of MatchY

Example

("x10ab20c30y" ~~ /[0-9]+/).whole.map(Int).sum()  # 60

arr = (~~)("x10ab20c30y", /[0-9]+/, true)
arr .= map(F(elt) if elt is MatchY "[${elt.whole}]" else elt)
arr.join("")  # "x[10]ab[20]c[30]y"