Skip to content

Instantly share code, notes, and snippets.

@Tulakshana
Last active November 22, 2017 15:55
Show Gist options
  • Save Tulakshana/9963a91d523c843e33525f14431efb0c to your computer and use it in GitHub Desktop.
Save Tulakshana/9963a91d523c843e33525f14431efb0c to your computer and use it in GitHub Desktop.
This String extension contains a convenient method to replace characters in a CharacterSet with a given String.
func stringByReplacing(charSet: CharacterSet, with string: String) -> String {
let components = self.components(separatedBy: charSet)
return components.joined(separator: string)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment