CFStringFindWithOptionsHeader: CFString.h

Searches for a substring within a range of the characters represented by a CFString object and, if the substring is found, returns its range within the object's characters.

Boolean CFStringFindWithOptions (
    CFStringRef theString, 
    CFStringRef stringToFind, 
    CFRange rangeToSearch, 
    CFOptionFlags searchOptions, 
    CFRange *result
);
theString

Pass a reference to the CFString object to be searched.

stringToFind

Pass a reference to the CFString object containing the substring to search for in theString.

rangeToSearch

Pass the range of the characters to search in the CFString object referenced by theString.

searchOptions

Pass a bitfield of type CFOptionFlags containing one or more comparison-option flags (OR'd together if multiple) or, if you want no options, pass zero. The options include such features as localized comparison, case-insensitive comparison, and non-literal compariosn.

result

Pass an uninitialized CFRange structure (or initialized to (0,0)). On return, if the function result is TRUE, result contains the starting location and length of the found substring. You may pass NULL if you only want to know if the substring exists in the larger string.

function result

TRUE if the substring was found, FALSE otherwise.

DISCUSSION

The CFStringFindWithOptions function allows you to search only part of the characters of a CFString object 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 CFString object 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.


© 1999 Apple Computer, Inc. — (Last Updated 9/15/99)