Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.