خرید بک لینک

Vote count: 0

I have a String which is :

let s : String = "The dog ate the cat."

With the following patte :

let p : NSRegularExpression = try! NSRegularExpression(patte: "\w( )?dog( )?\w"), options: .CaseInsensitive)

My question is : How do I get the words before and after the patte's occurrence?

This is my current implementation :

let t : [NSTextCheckingResults] = p.matchesInString(s, options: [], NSMakeRange(0, NSString(string: s).length))
print(String(t[0].URL!))

However this does not retu the desired result.

What is wrong with my regular expression?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 20 ارديبهشت 1395 ساعت: 8:01

صفحه بندی