0

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?

guoxj
  • 1

1 Answers1

0

try NSString *videoRegexString = @"{\"type\":\"video\",.+?\"}"; (Note the question mark) the .+ may be consuming the \"}

smitec
  • 3,049
  • 1
  • 16
  • 12