Overview
The findIter() method returns an iterator that yields all non-overlapping matches of the regex pattern in the input text. This method is memory-efficient as it generates matches lazily instead of collecting them all at once like findAll().
Signature
public func findIter(text: Text): Result.Result<Iter.Iter<Match>, RegexError>
Parameters
| Parameter | Type | Description | 
|---|---|---|
| text | Text | The input string to search for matches | 
Return Value
Type: Result.Result<Iter.Iter<Match>, RegexError>
Success Case
Returns an iterator that yields Match objects, where each contains:
- The matched substring (
value) - The position of the match within the input string
 - Any captured groups
 - Match status (
#FullMatch) 
Error Case
Returns RegexError (#NotCompiled) if the pattern failed to compile during instantiation
Iteration Process
- Starts from the beginning of the input string
 - For each match found:
- Yields a 
Matchobject - Advances to the position after the current match
 
 - Yields a 
 - Continues until no more matches are found
 - Automatically handles the internal state between iterations
 
Match Generation
- Matches are generated one at a time as the iterator is consumed
 - Non-overlapping matches are guaranteed
 - The iteration order follows the text from left to right