class Match
src
class Match is Capture is Cool { ... }
Match objects are the result of a successful regex match. They store
a reference to the original string ( .orig ), positional and
named captures, the positions of the start and end of the match
in the original string, and a payload referred to as I<AST>
(abstract syntax tree), which can be used to build data structures
from complex regexes and gramamrs.
Submatches are also Match objects (or lists of Match objects,
if the corresponding regex was quantified), so each match object
can be seen as the root of a tree of match objects.
Methods
orig
Returns the original string that the regex was matched against.
from
Returns the index of the starting position of the match.
to
Returns the index of the end position of the match.
ast
Returns the AST (ie payload).
Str
Returns the matched text.
caps
Returns a list of pairs, with the index or submatch name as key and
the submatches as values. The list is ordered by starting position
of the submatches.
chunks
Returns a list of pairs, with the index or submatch name as key and
the submatches as values. The list is ordered by starting position
of the submatches.
Those parts of the string that were not matched by submatches are
interleaved with the other pairs, with the string ~ as key.
list
Returns a list of positional submatches.
hash
Returns a hash of named submatches.
prematch
Returns the part of the original string leading up to the match.
postmatch
Returns the part of the original string following the match.
make
method make(Match:D: Mu $ast)
Sets the AST to $ast , and returns it.