Instance Method

rangeOfString: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

- (NSRange)rangeOfString:(NSString *)searchString options:(NSStringCompareOptions)mask range:(NSRange)rangeOfReceiverToSearch;

Parameters

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 OR operator: NSCaseInsensitiveSearch, NSLiteralSearch, NSBackwardsSearch, and NSAnchoredSearch. See String Programming Guide for details on these options.

rangeOfReceiverToSearch

The range within the receiver for which to search for aString.

Raises an NSRangeException if

rangeOfReceiverToSearch

is invalid.

Return Value

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

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

- containsString:

Returns a Boolean value indicating whether the string contains a given string by performing a case-sensitive, locale-unaware search.

- localizedCaseInsensitiveContainsString:

Returns a Boolean value indicating whether the string contains a given string by performing a case-insensitive, locale-aware search.

- localizedStandardContainsString:

Returns a Boolean value indicating whether the string contains a given string by performing a case and diacritic insensitive, locale-aware search.

- rangeOfCharacterFromSet:

Finds and returns the range in the string of the first character from a given character set.

- rangeOfCharacterFromSet:options:

Finds and returns the range in the string of the first character, using given options, from a given character set.

- rangeOfCharacterFromSet:options:range:

Finds and returns the range in the string of the first character from a given character set found in a given range with given options.

- rangeOfString:

Finds and returns the range of the first occurrence of a given string within the string.

- rangeOfString:options:

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

- rangeOfString:options:range:locale:

Finds and returns the range of the first occurrence of a given string within a given range of the string, subject to given options, using the specified locale, if any.

- localizedStandardRangeOfString:

Finds and returns the range of the first occurrence of a given string within the string by performing a case and diacritic insensitive, locale-aware search.

- enumerateLinesUsingBlock:

Enumerates all the lines in the string.

- enumerateSubstringsInRange:options:usingBlock:

Enumerates the substrings of the specified type in the specified range of the string.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software