~~ multimethod
Methods
- ~~(haystack:Str, needle:Str, collect_unmatched:Bool=false) Source: stdlib.ngs:5082
Find all non-overlapping matches of a substring in a string. Returns
if collect_unmatched - Arr with each element being MatchSuccess or Str, if not collect_unmatched - Arr of MatchSuccess
- ~~(s:Str, r:RegExp, collect_unmatched:Bool=false) Source: stdlib.ngs:7670
Find all non-overlapping matches of regular expression in a string. Returns
if collect_unmatched - Arr with each element being MatchSuccess or Str, if not collect_unmatched - Arr of MatchSuccessExample
("x10ab20c30y" ~~ /[0-9]+/).whole.map(Int).sum() # 60 arr = (~~)("x10ab20c30y", /[0-9]+/, true) arr .= map(F(elt) if elt is MatchSuccess "[${elt.whole}]" else elt) arr.join("") # "x[10]ab[20]c[30]y"