Swift Get substring

February 22, 2015   ·   0 Comments

Screen Shot 2015-02-22 at 8.48.36 AM
     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

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Swift491

Swift

Amazon

adsbygoogle

Recent Posts

Categories

Amazon