CFStringFindWithOptions(_:_:_:_:_:)
Searches for a substring within a range of the characters represented by a string and, if the substring is found, returns its range within the object’s characters.
Declaration
func CFStringFindWithOptions(_ theString: CFString!, _ stringToFind: CFString!, _ rangeToSearch: CFRange, _ searchOptions: CFStringCompareFlags, _ result: UnsafeMutablePointer<CFRange>!) -> BoolParameters
- theString:
The string in which to to search for
stringToFind. - stringToFind:
The substring to search for in
theString. - rangeToSearch:
A range of the characters to search in
theString. The specified range must not exceed the length of the string. - searchOptions:
The option flags to control the search behavior. See String Comparison Flags for possible values. The flags Comparenumerically and Compareforcedordering are ignored.
- result:
On return, if the function result is
true, contains the starting location and length of the found substring. You may passNULLif you only want to know if the substring exists in the larger string.
Return Value
true if the substring was found, false otherwise.
Discussion
This function allows you to search only part of the characters of a string for a substring. It returns the found range indirectly, in the final result parameter. If you want to know if the entire range of characters represented by a string contains a particular substring, you can use the convenience function CFStringFind(_:_:_:). 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 CFStringCreateArrayWithFindResults(_:_:_:_:_:) function.
Depending on the comparison-option flags specified, the length of the resulting range might be different than the length of the search string.