Contents

localizedStandardRange(of:)

Finds and returns the range of the first occurrence of a given string, taking the current locale into account. Returns nil if the string was not found.

Declaration

func localizedStandardRange<T>(of string: T) -> Range<Self.Index>? where T : StringProtocol

Discussion

This is the most appropriate method for doing user-level string searches, similar to how searches are done generally in the system. The search is locale-aware, case and diacritic insensitive. The exact list of search options applied may change over time.