regex adverb :global

Documentation for regex adverb :global assembled from the following types:

language documentation Regexes

From Regexes

(Regexes) regex adverb :global

Instead of searching for just one match and returning a Match object, search for every non-overlapping match and return them in a List. In order to do this, use the :global adverb:

given 'several words here' {
    my @matches = m:global/\w+/;
    say @matches.elems;         # OUTPUT: «3␤» 
    say ~@matches[2];           # OUTPUT: «here␤» 

:g is shorthand for :global.