Last active
August 8, 2018 10:06
-
-
Save boraseoksoon/788dfe7bfc75c9b01eb830317873cd51 to your computer and use it in GitHub Desktop.
remove all match list strings to need to be removed in a given string
This file contains hidden or 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
| extension String { | |
| func remove(stringList: [String]) -> String { | |
| return stringList.reduce(self) { | |
| return $0.replacingOccurrences(of: $1, with: "") | |
| } | |
| } | |
| } | |
| let testEmStr = "<em>#<\\/em>swift" | |
| let trimStr = testEmStr.remove(stringList:["<em>", "<\\/em>"]) | |
| testEmStr // "<em>#<\\/em>swift" | |
| trimStr // "#swift" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment