Question

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

Was it helpful?

Solution 2

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

OTHER TIPS

You can match this from the left to the right using the following regex:

\d{2}[\u0600-\u06FF]\d{3}
  • \d{2} matches two consecutive digits.
  • [\u0600-\u06FF] matches a single letter.
  • \d{3} matches three consecutive digits.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top