假设我有
"<p>I need <a href='www.alink.com'> www.alink.com / x /y </a>, along with this. </p>"
我要获取文本:I need www.alink.com/x/y, along with this.
我尝试通过以下方式删除html:
someString?.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
然后我得到:I need www.alink.com / x / y, along with this.
我需要没有空格的链接文本,该怎么办?
答案 0 :(得分:2)
尝试仅用字符替换空格和下一个下一个字符。
ans="Hello i am goutham /t /n /m"
ans.replace(" /", "/")
给出:
'Hello i am goutham/t/n/m'