Skip to content

Instantly share code, notes, and snippets.

@josephzhang23
Created November 8, 2017 23:10
Show Gist options
  • Select an option

  • Save josephzhang23/5c3a221fe67c86a983c0dfc43bc3469e to your computer and use it in GitHub Desktop.

Select an option

Save josephzhang23/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