Created
December 28, 2018 22:04
-
-
Save 10Macit/6beab310d6d9a12d9e97ca75b7f9a5b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "Türkiye plaka kodu için regular expression Swift 4.2" | |
# "99 X 9999", "99 X 99999" | |
# "99 XX 999", "99 XX 9999" | |
# "99 XXX 99", "99 XXX 999" | |
# "boşluk karakterleri silme" | |
let plate = self.plateStr.replacingOccurrences(of: " ", with: "").localizedUppercase | |
public static func isValidPlate(candidate: String) -> Bool { | |
let pattern = "(0[1-9]|[1-7][0-9]|8[01])(([A-Z])(\\d{4,5})|([A-Z]{2})(\\d{3,4})|([A-Z]{3})(\\d{2,3}))" | |
let predicate = NSPredicate(format: "self MATCHES [c] %@", pattern) | |
return predicate.evaluate(with: candidate) | |
} | |
isValidPlate(plate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eline saglik