Swift Get substring


     let myString = "#12345678"
        let myfind: Character = "#"
        if let idx = find(myString, myfind){
        var myNewString = myString.substringWithRange(( advance(myString.startIndex,0+1)..<advance(myString.endIndex, 0)))
        }

Output:
12345678
Screen Shot 2015-02-22 at 8.48.36 AM

let myString = "[ABCDEFGHI]"
        let startIndex = advance(myString.startIndex, 1)
        let endIndex = advance(myString.endIndex, -1)
        let range = startIndex..<endIndex
        var myNewString = myString.substringWithRange( range )

Output:
ABCDEFGHI

Screen Shot 2015-02-22 at 8.50.20 AM


Leave a Reply