我有如下字符串
<p><strong>I am a strongPerson</strong></p>
我想像这样隐藏这个字符串
<p><strong>I am a weakPerson</strong></p>
当我尝试下面的代码时
let old = "<p><strong>I am a strongPerson</strong></p>"
let new = old.replacingOccurrences(of: "strong", with: "weak")
print("\(new)")
我得到像这样的输出
<p><weak>I am a weakPerson</weak></p>
但我需要这样的输出
<p><strong>I am a weakPerson</strong></p>
我的条件是
1.仅当单词不包含“<>”之类的HTML标签时才需要替换。
帮我搞定。提前致谢。