Created
May 7, 2020 21:46
-
-
Save JMatharu/090e01876cd6b11ad55edaaafb82f4b7 to your computer and use it in GitHub Desktop.
SplitString
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 StringProtocol { | |
var splitByString: [SubSequence] { | |
return self.split(separator: " ") | |
} | |
func seperateByCharacter(_ char: Character) -> [SubSequence] { | |
return self.split(separator: char) | |
} | |
} | |
"Hello! Swift String.".splitByString //["Hello!", "Swift", "String."] | |
"1997,Ford,E350".seperateByCharacter(",") //["1997", "Ford", "E350"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment