Get substring from range

 Problem

I have a string and want to retrieve a substring found within a specific range.



 Recipe


// String literal
let s = "Hello World"

// Get the substring from position 6
// to the end: 'World'

let sub = s[s.startIndex.advancedBy(6)..<s.endIndex]
print(s)
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground