我想将字符串aaaa{\"type\":\"video\",\"title\":\"a\",manyothershere\"}ssss替换为aaaavideossss
表示字符串{"type":" video ","title":"a",balabala"}为video
我使用RegexKitLite,我尝试了下面的代码,但它不能工作。
NSString *videoRegexString = @"{\"type\":\"video\",.+\"}";
NSString *replacedStr = [@"aaaa{\"type\":\"video\",\"title\":\"sdf\",manyothershere\"}ssss" stringByReplacingOccurrencesOfRegex:videoRegexString withString:@"[video]"];我认为replacedStr是"aaaavideossss“,但它是零,我错了吗?
发布于 2011-08-30 12:58:54
尝试NSString *videoRegexString = @"{\"type\":\"video\",.+?\"}"; (注意问号) .+可能正在使用\"}
https://stackoverflow.com/questions/7238846
复制相似问题