Skip to content

Match

A single matched span within a string.

Match values are returned by indexing a Captures. Coercing one with str produces the matched text.

Fields

end @ Int

The byte offset of the end of the match within the haystack.

Example
let date = Regex r"(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})"
let caps = date.match "prefix 2024-03-15 suffix"

let year = caps["year"]
echo $year         # => 2024
echo $year.start   # => 7
echo $year.end     # => 11
Open in playground
start @ Int

The byte offset of the start of the match within the haystack.