I want to learn the best/simplest way to turn a string into another string but with only a subset, starting at the beginning and going to the last index of a character.
edit/update:
In Swift 4 or later (Xcode 10.0+) you can use the new BidirectionalCollection method lastIndex(of:)
func lastIndex(of element: Element) -> Int?
let string = "www.stackoverflow.com" if let lastIndex = string.lastIndex(of: ".") { let subString = string[..