Instance Method

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.

Declaration

- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)searchSet options:(NSStringCompareOptions)mask range:(NSRange)rangeOfReceiverToSearch;

Parameters

aSet

A character set. This value must not be nil.

Raises an NSInvalidArgumentException if aSet is nil.

mask

A mask specifying search options. The following options may be specified by combining them with the C bitwise OR operator: NSAnchoredSearch, NSBackwardsSearch.

aRange

The range in which to search. aRange must not exceed the bounds of the receiver.

Raises an NSRangeException if aRange is invalid.

Return Value

The range in the receiver of the first character found from aSet within aRange. Returns a range of {NSNotFound, 0} if none of the characters in aSet are found.

Discussion

This method does not perform any Unicode normalization on the receiver, so canonically equivalent forms will not be matched. For example, searching the string “strüdel”—containing the decomposed characters “u” (U+0075 LATIN SMALL LETTER U) and “¨” (U+0308 COMBINING DIAERESIS)—with a character set containing the precomposed character “ü” (U+00FC LATIN SMALL LETTER U WITH DIAERESIS) would return the range {NSNotFound, 0}, because none of the characters in the set are found.

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.

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

Finds and returns the range of the first occurrence of a given string, within the given range of 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.