Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@josephchang10
Created November 8, 2017 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephchang10/5c3a221fe67c86a983c0dfc43bc3469e to your computer and use it in GitHub Desktop.
Save josephchang10/5c3a221fe67c86a983c0dfc43bc3469e to your computer and use it in GitHub Desktop.
The more elegant way to remove all characters after specific character in the String object in Swift
var str = "str.str"
if let dotRange = str.range(of: ".") {
str.removeSubrange(dotRange.lowerBound..<str.endIndex)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment