A structure representing the capture groups from a regex match.
Contains the original string (haystack) and a buffer of positions marking the start and end of each capture group.
- buffer : Array haystack.ValidPosPlusOne
Instances For
Equations
- Regex.instReprCapturedGroups = { reprPrec := Regex.instReprCapturedGroups.repr }
def
Regex.instReprCapturedGroups.repr
{haystack✝ : String}
:
CapturedGroups haystack✝ → Nat → Std.Format
Equations
- One or more equations did not get rendered due to their size.
Instances For
instance
Regex.instDecidableEqCapturedGroups
{haystack✝ : String}
:
DecidableEq (CapturedGroups haystack✝)
Equations
- Regex.instInhabitedCapturedGroups.default = { buffer := default }
Instances For
Equations
Gets a specific capture group as a substring.
self: The captured groupsindex: The index of the capture group to retrieve (0 for the entire match)- Returns: An optional substring representing the capture group, or
noneif the group didn't participate in the match
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Regex.CapturedGroups.get_str_eq_some
{haystack : String}
{self : CapturedGroups haystack}
{index : Nat}
{s : String.Slice}
(h : self.get index = some s)
:
Converts all capture groups to an array of optional substrings.
self: The captured groups- Returns: An array where each element is either a substring for a capture group
or
noneif that group didn't participate in the match
Equations
- self.toArray = Regex.CapturedGroups.toArray.go self 0 #[]
Instances For
@[irreducible]
def
Regex.CapturedGroups.toArray.go
{haystack : String}
(self : CapturedGroups haystack)
(i : Nat)
(accum : Array (Option String.Slice))
:
Equations
Instances For
A structure that enables iterating through all capture groups of regex matches in a string.
Provides a stateful iterator for finding all regex matches and their capture groups in a haystack string.
- regex : Regex
- currentPos : haystack.ValidPosPlusOne
Instances For
Equations
- Regex.instReprCaptures = { reprPrec := Regex.instReprCaptures.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Regex.Captures.next?
{haystack : String}
(self : Captures haystack)
:
Option (CapturedGroups haystack × Captures haystack)
Gets the next match and its capture groups.
self: The captures iterator- Returns: An optional pair containing the captured groups and an updated iterator,
or
noneif no more matches are found
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Regex.Captures.lt_next?_some'
{haystack : String}
{groups : CapturedGroups haystack}
{c c' : Captures haystack}
(h : c.next? = some (groups, c'))
:
Equations
- c.lt c' = (c.currentPos < c'.currentPos)
Instances For
Equations
theorem
Regex.Captures.wellFounded_gt
{haystack : String}
:
WellFounded fun (p q : Captures haystack) => q < p
instance
Regex.Captures.instWellFoundedRelation
{haystack : String}
:
WellFoundedRelation (Captures haystack)
Equations
- Regex.Captures.instWellFoundedRelation = { rel := fun (p q : Regex.Captures haystack) => q < p, wf := ⋯ }
instance
Regex.Captures.instStreamCapturedGroups
{haystack : String}
:
Std.Stream (Captures haystack) (CapturedGroups haystack)
Equations
Creates a new Captures iterator for a regex pattern and input string.
regex: The compiled regex pattern to use for matchings: The input string to search in- Returns: A
Capturesiterator positioned at the start of the string
Equations
- regex.captures s = { regex := regex, currentPos := s.startValidPosPlusOne }