Search code examples
regexasp.net-mvc-4combinationspersian

Regular expression for license plate number in Iran with Persian letters and digits


I need a regular expression matching Iranian cars' license plate number. the combination consists of a two digit number followed by a Persian letter and then another three digit number
like in the picture below:

It's necessary to allow user to input English digits (1-9) because some browsers or operating systems don't support Persian digits, but the letter MUST be Persian and cuz it's always supported.

EDIT: Anyway I'm using c# in ASP.net MVC


Solution

  • Found what I was looking for :

    "[۱-۹\\d]{2}[\u0600-\u06FF][۱-۹\\d]{3}"  
    

    Works flawlessly with MVC data annotations, which I'm currently using it for
    [RegularExpression("[۱-۹\\d]{2}[\u0600-\u06FF][۱-۹\\d]{3}", ErrorMessage = "It's wrong!")]

    Thank to Sniffer who helped me find the correct answer. :)
    Wish you all find this helpful