我有这样一个字符串:
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"];
谁能帮我解决@"????"模式?
最佳答案
这就是我所追求的模式:@(.*?):(.*?)]
。感谢转至 this question .
关于objective-c - NSString 替换正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12143182/