12.2.4 Regexp Match Results
The whole value and elements of captures are intended to be strings, byte strings, or ranges, depending on how the match is produced. For example, RX.match with a regexp in character mode on a string input will produce a RXMatch object whose whole is a string. The RX.match_range method produces a RXMatch object whose whole is a range.
A RXMatch object is Listable and Indexable. Its Listable.to_list conversion is same as [whole] ++ captures. Indexing by an integer accesses the same result as indexing the object’s list, but capture-group names (which are the keys of capture_names) can also be used as indices.
RXMatch(Bytes.copy(#"axz"), [], {})
RXMatch(Bytes.copy(#"axz"), [], {})
> rx'any "x" any'.match_range("axz")
RXMatch(0 .. 3, [], {})
> m
RXMatch("axz", ["a", "z"], {#'post: 2, #'pre: 1})
> m[0]
"axz"
> m[1]
"a"
> m[#'pre]
"a"