Last active
August 25, 2021 21:52
-
-
Save elenipapanik/e024d20b9acf289454eb742c725864e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stringByStrippingHTMLElementsWithRegex() -> String { | |
let trimmedString = self.stringByReplacingOccurrencesOfString("<[^>]+>", withString: "", options: .RegularExpressionSearch, range: nil) | |
let trimmedStringFromNewLine = trimmedString.stringByReplacingOccurrencesOfString("\n", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil) | |
let trimmedStringFromWhiteSpaces = trimmedStringFromNewLine.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) | |
return trimmedStringFromWhiteSpaces | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment