我有一个字符串,如下所示:
NSString* msg = @"Hello this is a new message to @[123:Dr Zoidberg] and his nippers";
我想使用-stringByReplacingMatchesInString:options:range:withTemplate:
方法将这个模式转换成:
NSString* msg = @"Hello this is a new message to Dr Zoidberg and his nippers";
这是我目前的进展:
这是我目前的进展:
NSString* msg = @"Hello this is a new message to @[123:Dr Zoidberg] and his nippers";
NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern: @"????"
options: NSRegularExpressionCaseInsensitive
error: nil];
NSString* plainText = [regex stringByReplacingMatchesInString: msg
options: 0
range: NSMakeRange(0, [msg length])
withTemplate: @"$2"];
有人能帮我解释一下@"????"模式吗?
@[123:Dr Zoidberg]
中,可以用什么替换数字123
? - mmdemirbas