0

Suppose I have:

"<p>I need <a href='www.alink.com'> www.alink.com / x /y </a>, along with this. </p>"

I want to get the text : I need www.alink.com/x/y, along with this.

I tried removing html by:

someString?.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)

then I get: I need www.alink.com / x / y, along with this.

I need the link text without the space, how can I do that?

Shaido
  • 27,497
  • 23
  • 70
  • 73
Arafin Russell
  • 1,487
  • 1
  • 18
  • 37

1 Answers1

2

Try to replace the whitespace and the next coming character with only the character.

ans="Hello i am goutham /t /n /m"
ans.replace(" /", "/")

which gives:

'Hello i am goutham/t/n/m'
Shaido
  • 27,497
  • 23
  • 70
  • 73