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.
Swift 2.0 The code below is tested on XCode 7.2 . Please refer to the attached screenshot at the bottom
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var mainText = "http://stackoverflow.com"
var range = Range(start: mainText.startIndex.advancedBy(7), end: mainText.startIndex.advancedBy(24))
var subText = mainText.substringWithRange(range)
//OR Else use below for LAST INDEX
range = Range(start: mainText.startIndex.advancedBy(7), end: mainText.endIndex)
subText = mainText.substringWithRange(range)
}
}