Objective c NSString STRINGBYREPLAcingOfregex发生率

Objective c NSString STRINGBYREPLAcingOfregex发生率,objective-c,regex,ios,nsstring,Objective C,Regex,Ios,Nsstring,我看到了这个方法的很多用法:stringByReplacingOccurrencesOfRegex on NSString等等。但我收到一条警告,说找不到这个实例方法,并且在运行时由于“未识别的选择器发送到…”而崩溃 有什么想法吗?我从未见过这种方法,但您可以使用这种方法来实现正则表达式操作: /* Replace all occurrences of the target string in the specified range with replacement. Specified com

我看到了这个方法的很多用法:stringByReplacingOccurrencesOfRegex on NSString等等。但我收到一条警告,说找不到这个实例方法,并且在运行时由于“未识别的选择器发送到…”而崩溃


有什么想法吗?

我从未见过这种方法,但您可以使用这种方法来实现正则表达式操作:

/* 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);

很抱歉,格式限制将其限制为两行,请检查NSString.h以获取此代码。

该方法是由提供的扩展。

我最终使用了另一种解决方案以满足需要。但是你的答案是对的。user523234,你能在这里写下你的另一个解决方案吗?