【发布时间】:2021-06-29 08:58:16
【问题描述】:
我有这个内容:
var a = "Hello <sup foot_note=\"81277\">1</sup> World"
我想删除整个 html 标签:<sup foot_note=\"81277\">1</sup>
我用这段代码试了一下:
let str1 = getText().replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
var str2 = str1.replacingOccurrences(of: "&[^;]+;", with: "", options: .regularExpression, range: nil)
这不会删除“1”,所以我得到“Hello 1 World”。我该如何解决这个问题?
【问题讨论】:
-
感谢这项工作!