var string = "hello Swift"

if string.rangeOfString("Swift") != nil{
    println("exists")
}

// alternative: not case sensitive
if string.lowercaseString.rangeOfString("swift") != nil {
    println("exists")
}

  
        let string2 = "Hello.World"
        let needle: Character = "."
        if let idx = find(string2, needle) {
            let pos = distance(string2.startIndex, idx)
            println("Found \(needle) at position \(pos)")
        }
        else {
            println("Not found")
        }

By admin-powenko

Dr. Powen Ko is a teacher and CEO on LoopTek LLC, and like to teaching. if you need to class, please let PowenKo know, he will love to service and sharing. LoopTek web site is www.looptek.com

Leave a Reply