我有一个小问题,我使用一个代码段从iOS字符串中删除html代码:
while ((r = [s rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
现在我需要移除一些块,比如。为什么此代码段不起作用:
while ((r = [s rangeOfString:@"<style[^>]+style>" options:NSRegularExpressionSearch]).location != NSNotFound)
s = [s stringByReplacingCharactersInRange:r withString:@""];
感谢您的帮助!
答案 0 :(得分:0)
试试这个:
while ((r = [s rangeOfString:@"<style[^>]+>[^>]+</style>" options:NSRegularExpressionSearch]).location != NSNotFound) {
s = [s stringByReplacingCharactersInRange:r withString:@""];
}