Why does the following sentence:
let potential = "Kaline bypassed the Minors to join the Tigers at 18. By 20"
pass through this RegEx if statement:
if (potential.matches("(?i)No.\\s?-?\\s?[A-Z0-9]") ||
potential.matches("(?i)N0.\\s?-?\\s?[A-Z0-9]"))
{
print("in"
}
extension String {
func matches(_ regex: String) -> Bool {
return self.range(of: regex, options: .regularExpression, range: nil, locale: nil) != nil
}
}