I'm try to use the validate medicare code in How do I validate an Australian Medicare number? thread,
I replace following line
let expression =try!NSRegularExpression(pattern:pattern, options: NSRegularExpressionOptions.CaseInsensitive)
with code below,
var expression :NSRegularExpression
do {
expression = NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.CaseInsensitive)
} catch {
// Handling error
println("error medicare val")
}
But I'm getting errors as
Expected while in do-while block
and
brace block of statements is an unused clausure
I'm not sure how to solve this error. I'm using Xcode 6.2.
Update
I tried Parth's answer and I got following errors,
consecutive statements on a line must be separated by ';' for this line
expression = try NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.CaseInsensitive)
Also
} catch let error as NSError {
// Handling error
print("error medicare val\(error)")
}
code got
Expected while in do-while block
brace block of statements is an unused clausure
Expected expression
consecutive statements on a line must be separated by ';'