RegexKitLite 匹配吗?
我想将字符串 aaaa{\"type\":\"video\",\"title\":\"a\",manyothershere\"}ssss 替换为 aaaa[video]ssss
这意味着字符串 {"type":"video","title":"a",balabala"} 到 [video]
我使用 RegexKitLite,我尝试了下面的代码,但它不起作用。
NSString *videoRegexString = @"{\"type\":\"video\",.+\"}";
NSString *replacedStr = [@"aaaa{\"type\":\"video\",\"title\":\"sdf\",manyothershere\"}ssss" stringByReplacingOccurrencesOfRegex:videoRegexString withString:@"[video]"];
我想被替换的Str是“aaaa[video]ssss”但它是零 我错了吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
NSString *videoRegexString = @"{\"type\":\"video\",.+?\"}";
(注意问号).+
可能正在消耗\"}
try
NSString *videoRegexString = @"{\"type\":\"video\",.+?\"}";
(Note the question mark) the.+
may be consuming the\"}