Reputation: 1
i want to replace the string aaaa{\"type\":\"video\",\"title\":\"a\",manyothershere\"}ssss to aaaa[video]ssss
this means the string {"type":"video","title":"a",balabala"} to [video]
i use RegexKitLite,i tried the code below ,but it doesn't work.
NSString *videoRegexString = @"{\"type\":\"video\",.+\"}";
NSString *replacedStr = [@"aaaa{\"type\":\"video\",\"title\":\"sdf\",manyothershere\"}ssss" stringByReplacingOccurrencesOfRegex:videoRegexString withString:@"[video]"];
i suppose the replacedStr is "aaaa[video]ssss" but it's nil am i wrong?
Upvotes: 0
Views: 121
Reputation: 3049
try NSString *videoRegexString = @"{\"type\":\"video\",.+?\"}";
(Note the question mark) the .+
may be consuming the \"}
Upvotes: 0