这是我的字符串
<![CDATA[https://2134114018c95327dd42-9b7f7e536ddb2ed4dd0d87c2f0e46492.ssl.cf2.rackcdn.com/340x340/8663034_19227_$2014_03_28_10_30_34_3934.JPG]]>
我在这一点上陷入困境。我只是想从这个字符串中删除CDATA。是否有快速的解决方法?
答案 0 :(得分:2)
[str stringByReplacingOccurrencesOfString:@"CDATA" withString:@""];
这应该有帮助
编辑:
NSString *haystack = @"<![CDATA[https://2134114018c95327dd42-9b7f7e536ddb2ed4dd0d87c2f0e46492.ssl.cf2.rackcdn.com/340x340/8663034_19227_$2014_03_28_10_30_34_3934.JPG]]>";
NSString *prefix = @"<![CDATA[";
NSString *suffix = @"]]>";
NSRange needleRange = NSMakeRange(prefix.length,
haystack.length - prefix.length - suffix.length);
NSString *needle = [haystack substringWithRange:needleRange];
针是你的网址