Searches for a substring within a string and, if it is found, yields the range of the substring within the object's characters.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Core Foundation
The string in which to search for
The string to search for in
Flags that select different types of comparisons, such as localized comparison, case-insensitive comparison, and non-literal comparison. If you want the default comparison behavior, pass
0. See String Comparison Flags for the available flags.
This function is a convenience when you want to know if the entire range of characters represented by a string contains a particular substring. If you want to search only part of the characters of a string, use the
CFString function. Both of these functions return upon finding the first occurrence of the substring, so if you want to find out about multiple occurrences, call the
Depending on the comparison-option flags specified, the length of the resulting range might be different than the length of the search string.