firstRange(of:)
Finds and returns the range of the first occurrence of a given regex within the collection.
Declaration
func firstRange(of regex: some RegexComponent) -> Range<Self.Index>?Parameters
- regex:
The regex to search for.
Return Value
A range in the collection of the first occurrence of regex. Returns nil if regex is not found.