mardi 4 août 2015

Remove empty tags from html String in Swift

I am trying to remove empty <p></p> tags from my string whose content is html. I have tried to use regex such as;

let deleteRegex = NSRegularExpression(pattern: "<p[^>]*><\\/p[^>]*>", options: NSRegularExpressionOptions.allZeros, error: nil)
deleteRegex?.stringByReplacingMatchesInString(comment.text!, options: NSMatchingOptions.allZeros, range: NSMakeRange(0, (comment.text! as NSString).length), withTemplate: "")

However i got no success. Any help would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire