Replaces all occurrences of a substring within a given range.
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The substring to search for in
The replacement string for
The range within which to search 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
CFStringCompareFlags for the available flags.
The number of instances of
stringToFind that were replaced.
The possible values of
compareOptions are combinations of the
kCFCompareBackwards option can be used to replace a substring starting from the end, which could produce different results. For example, if the parameter
theString is “AAAAA”,
stringToFind is “AA”, and
replacementString is “B”, then the result is normally “BBA”. However, if the
kCFCompareBackwards constant is used, the result is “ABB.”
kCFCompareAnchored option assures that only anchored but multiple instances are found (the instances must be consecutive at start or end). For example, if the parameter
theString is “AAXAA”,
stringToFind is “A”, and
replacementString is “B”, then the result is normally “BBXBB.” However, if the
kCFCompareAnchored constant is used, the result is “BBXAA.”
CFMutableString Miscellaneous Functions
Appends the characters of a string to those of a CFMutableString object.
Appends a formatted string to the character contents of a CFMutableString object.
Changes the first character in each word of a string to uppercase (if it is a lowercase alphabetical character).
Folds a given string into the form specified by optional flags.
Inserts a string at a specified location in the character buffer of a CFMutableString object.
Changes all uppercase alphabetical characters in a CFMutableString to lowercase.
Normalizes the string into the specified form as described in Unicode Technical Report #15.
Enlarges a string, padding it with specified characters, or truncates the string.
Replaces part of the character contents of a CFMutableString object with another string.
Replaces all characters of a CFMutableString object with other characters.
Trims a specified substring from the beginning and end of a CFMutableString object.
Changes all lowercase alphabetical characters in a CFMutableString object to uppercase.