I saw a lot of usages of this method: stringByReplacingOccurrencesOfRegex on NSString on SO. But I got a waring that said this instance method is not found and at running time cr开发者_开发百科ashing with a "unrecognized selector sent to.."
Any idea?
That method is an extension provided by RegExKitLite.
I've never seen that method, but you can use this one to achieve regular expression manipulation:
/* Replace all occurrences of the target string in the specified range with replacement. Specified compare options are used for matching target. If NSRegularExpressionSearch is specified, the replacement is treated as a template, as in the corresponding NSRegularExpression methods, and no other options can apply except NSCaseInsensitiveSearch and NSAnchoredSearch.
*/
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options range:(NSRange)searchRange NS_AVAILABLE(10_5, 2_0);
Sorry about the formatting restrictions forcing it onto two lines, check out NSString.h for this code
精彩评论