Documentation

Regex.Regex.Captures

structure Regex.CapturedGroups (haystack : String) :

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.

Instances For
    def Regex.instReprCapturedGroups.repr {haystack✝ : String} :
    CapturedGroups haystack✝NatStd.Format
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Regex.instDecidableEqCapturedGroups.decEq {haystack✝ : String} (x✝ x✝¹ : CapturedGroups haystack✝) :
      Decidable (x✝ = x✝¹)
      Equations
      Instances For
        def Regex.CapturedGroups.get {haystack : String} (self : CapturedGroups haystack) (index : Nat) :

        Gets a specific capture group as a substring.

        • self: The captured groups
        • index: The index of the capture group to retrieve (0 for the entire match)
        • Returns: An optional substring representing the capture group, or none if 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) :
          s.str = haystack

          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 none if that group didn't participate in the match
          Equations
          Instances For
            @[irreducible]
            Equations
            Instances For
              structure Regex.Captures (haystack : String) :

              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.

              Instances For
                instance Regex.instReprCaptures {haystack✝ : String} :
                Repr (Captures haystack✝)
                Equations
                def Regex.instReprCaptures.repr {haystack✝ : String} :
                Captures haystack✝NatStd.Format
                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 none if no more matches are found
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    theorem Regex.Captures.zeroth_group_some_of_next?_some {haystack : String} {self next : Captures haystack} {groups : CapturedGroups haystack} (h : self.next? = some (groups, next)) :
                    (groups.get 0).isSome = true
                    theorem Regex.Captures.lt_next?_some' {haystack : String} {groups : CapturedGroups haystack} {c c' : Captures haystack} (h : c.next? = some (groups, c')) :
                    def Regex.Captures.lt {haystack : String} (c c' : Captures haystack) :
                    Equations
                    Instances For
                      instance Regex.Captures.instLT {haystack : String} :
                      LT (Captures haystack)
                      Equations
                      @[simp]
                      theorem Regex.Captures.lt_next?_some {haystack : String} {groups : CapturedGroups haystack} {c c' : Captures haystack} (h : c.next? = some (groups, c')) :
                      c < c'
                      theorem Regex.Captures.wellFounded_gt {haystack : String} :
                      WellFounded fun (p q : Captures haystack) => q < p
                      Equations
                      def Regex.captures (regex : Regex) (s : String) :

                      Creates a new Captures iterator for a regex pattern and input string.

                      • regex: The compiled regex pattern to use for matching
                      • s: The input string to search in
                      • Returns: A Captures iterator positioned at the start of the string
                      Equations
                      Instances For