正则表达式加引号:
NSString *aString = @"{q:\"你\",p:false,s:[\"你到底有没有爱过我\",\"你是我的小苹果\",\"你是我的眼\",\"你不知道的事\",\"你懂的\",\"你是男的我也爱\",\"你好\",\"逆战\",\"你是我兄弟\",\"你懂的网站\"]}"; aString = [aString stringByReplacingOccurrencesOfString:@"(\\w+)\\s*:" withString:@"\"$1\":" options:NSRegularExpressionSearch range:NSMakeRange(0,[aString length])]; NSLog(@"%@",aString); Sometimesy 15:27:14 {"q":"你","p":false,"s":["你到底有没有爱过我","你是我的小苹果","你是我的眼","你不知道的事","你懂的","你是男的我也爱","你好","逆战","你是我兄弟","你懂的网站"]}
原文链接:https://www.f2er.com/regex/359892.html