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?
