Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从NSString中剥离某些HTML标记_Html_Ios_Regex_Nsstring_Whitelist - Fatal编程技术网

从NSString中剥离某些HTML标记

从NSString中剥离某些HTML标记,html,ios,regex,nsstring,whitelist,Html,Ios,Regex,Nsstring,Whitelist,我试图从NSString实例中剥离某些HTML标记,但从javascript移植regexp会导致从字符串中剥离所有标记 我还使用Reggy测试了regexp,这表明它可以正常工作,但我无法让它在iOS中工作 我错过了什么 // remove all tags except the whitelisted ones (b,i,p,a,strong,br,ul,ol,li) NSRegularExpression *regex = [NSRegularExpression regularExpre

我试图从NSString实例中剥离某些HTML标记,但从javascript移植regexp会导致从字符串中剥离所有标记

我还使用Reggy测试了regexp,这表明它可以正常工作,但我无法让它在iOS中工作

我错过了什么

// remove all tags except the whitelisted ones (b,i,p,a,strong,br,ul,ol,li)
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<(?!/?(?:[bipa]|strong|br|ul|ol|li)\b)[^>]*>" options:0 error:&error];
result = [regex stringByReplacingMatchesInString:someString options:0 range:NSMakeRange(0, [someString length]) withTemplate:@""];
//删除除白名单上的标签(b、i、p、a、strong、br、ul、ol、li)以外的所有标签
NSRegularExpression*regex=[NSRegularExpression regular expressionwithpattern:@“]*>”选项:0错误:&error];
结果=[regex StringByRePlacingMatchesInstalling:someString选项:0范围:NSMakeRange(0,[someString长度]),带模板:@”“;
您是否尝试过一种新方法?