ios - Strip out html tags from a string -
i'm trying remove html tags string can output clean text.
[actually works]
let str = string.stringbyreplacingoccurrencesofstring("<[^>]+>", withstring: "", options: .regularexpressionsearch, range: nil) print(str)
edit: swift 3
let str = string.replacingoccurrences(of: "<[^>]+>", with: "", options: .regularexpression, range: nil) print(str)
hmm, tried function , worked on small example:
var string = "<!doctype html> <html> <body> <h1>my first heading</h1> <p>my first paragraph.</p> </body> </html>" let str = string.stringbyreplacingoccurrencesofstring("<[^>]+>", withstring: "", options: .regularexpressionsearch, range: nil) print(str) //output " first heading first paragraph. "
can give example of problem?
Comments
Post a Comment