range(of:options:range:)
Finds and returns the range of the first occurrence of a given string, within the given range of the string, subject to given options.
Declaration
func range(of searchString: String, options mask: NSString.CompareOptions = [], range rangeOfReceiverToSearch: NSRange) -> NSRangeParameters
- searchString:
The string for which to search.
- mask:
A mask specifying search options. The following options may be specified by combining them with the C bitwise
ORoperator:NSCaseInsensitiveSearch,NSLiteralSearch,NSBackwardsSearch, andNSAnchoredSearch. See 10000035i for details on these options. - rangeOfReceiverToSearch:
The range within the receiver for which to search for
aString.Raises an
NSRangeExceptionifrangeOfReceiverToSearchis invalid.
Return Value
An NSRange structure giving the location and length in the receiver of
Discussion
searchString
within
rangeOfReceiverToSearch
in the receiver, modulo the options in mask. The range returned is relative to the start of the string, not to the passed-in range. Returns {``NSNotFound``, 0} if
searchString
is not found or is empty ("").
Discussion
NSString objects are compared by checking the Unicode canonical equivalence of their code point sequences. T
he length of the returned range and that of
searchString
may differ if equivalent composed character sequences are matched.
See Also
Finding Characters and Substrings
contains(_:)localizedCaseInsensitiveContains(_:)localizedStandardContains(_:)rangeOfCharacter(from:)rangeOfCharacter(from:options:)rangeOfCharacter(from:options:range:)range(of:)range(of:options:)range(of:options:range:locale:)localizedStandardRange(of:)enumerateLines(_:)enumerateSubstrings(in:options:using:)