Contents

range(of:options:)

Finds and returns the range of the first occurrence of a given string within the string, subject to given options.

Declaration

func range(of searchString: String, options mask: NSString.CompareOptions = []) -> NSRange

Parameters

  • searchString:

    The string to search for.

  • mask:

    A mask specifying search options. For possible values, see Compareoptions.

Return Value

An NSRange structure giving the location and length in the receiver of the first occurrence of

Discussion

searchString,

modulo the options in mask. Returns {``NSNotFound``, 0} if

searchString

is not found or is empty ("").

Discussion

Invokes range(of:options:range:) with the options specified by mask and the entire extent of the receiver as the range.

NSString objects are compared by checking the Unicode canonical equivalence of their code point sequences. The length of the returned range and that of

searchString

may differ if equivalent composed character sequences are matched.

See Also

Finding Characters and Substrings