Documentation

Regex.Regex.Captures

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

    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

      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 :

          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

            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

              Gets the number of remaining characters to process in the haystack string.

              • self: The captures iterator
              • Returns: The number of remaining positions
              Equations
              Instances For
                theorem String.Pos.sizeOf_lt_iff {p p' : Pos} :
                sizeOf p < sizeOf p' p < p'
                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
                • regex.captures s = { regex := regex, haystack := s, currentPos := 0 }
                Instances For