如何从字符串中删除HTML标签,以便可以输出纯文本?
let str = string.stringByReplacingOccurrencesOfString("<[^>]+>", withString: "", options: .RegularExpressionSearch, range: nil)
print(str)
只需使用HTML解析器。
—
顺磁牛角包
大声笑stackoverflow ...如何关闭作为“主题”?这是“ Swift remove html tags”的#1 Google搜索结果。
—
canhazbits 2016年
@canhazbits我知道是对的!单击重新打开以提名它以再次重新打开。
—
带领
Swift 3:string.replacingOccurrences(of:“ <[^>] +>”,带有:“”,选项:.regularExpression,范围:nil)
—
etayluz