Reputation: 3790
Is it any way to validate regular expression in Swift that syntax of regex is correct?
E.g. user enters regex in TextField and I need to validate that one's syntax is correct.
Upvotes: 0
Views: 359
Reputation: 26006
From the doc:
+ regularExpressionWithPattern:options:error:
For error
parameter:
An out value that returns any error encountered during initialization. Returns an
NSError
object if the regular expression pattern is invalid; otherwise returnsnil
.
- initWithPattern:options:error:
For error
parameter:
An out value that returns any error encountered during initialization. Returns an
NSError
object if the regular expression pattern is invalid; otherwise returnsnil
.
Upvotes: 1