help to remake the regulars for parsing the 9-digit car number (for the 8-digit found)

8-digit format: aXXXaXX

9-digit format: 邪啸啸啸a邪啸啸啸

Where a is the letters of the Russian alphabet, X - numbers

For the 8th digit:

/^[邪-褟褢\-\s]{1}[0-9]{3}(?<!0{3})[邪-褟褢\-\s]{2}[0-9]{2}$/ 
  • one
    Replace [0-9]{2}$ with [0-9]{3}$ or [0-9]{2,3}$ (if both formats are required). Is it for PHP? Is it true that the first three digits should not be zeros? - Wiktor Stribi偶ew
  • 2
    And do not forget about the numbers of taxis and vehicles, there is one less letter and the order is slightly different. - Kromster
  • one
    And do not forget that in the numbers there are far from all the letters of the Russian alphabet. The letters "I", for example, no. - Enikeyschik
  • 3
    and to be exact, only 12 letters: 袗袙袝袣袦袧袨袪小孝校啸 . - Fat-Zer
  • one
    Y is the only letter by which it can be understood that it is really Cyrillic) - vp_arth

2 answers 2

In general, with the foregoing in the comments, the regular for 8/9 might look like this:

 /^[袗袙袝袣袦袧袨袪小孝校啸]\d{3}(?<!000)[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{2,3}$/ui 

Well, yes, it is worth clarifying that this only works for private vehicle numbers.

There are also:

  • transport / taxi: /^[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{3}(?<!000)\d{2,3}$/ui
  • trailers: /^[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{4}(?<!0000)\d{2,3}$/ui
  • Moto, c / x technique: /^\d{4}(?<!0000)[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{2,3}$/ui
  • transit: /^[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{3}(?<!000)[袗袙袝袣袦袧袨袪小孝校啸]\d{2,3}$/ui
  • exit: /^孝[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{3}(?<!000)\d{2,3}$/ui

There is still the Interior Ministry, diplomats, military, federal (without the region) ...

  • one
    In fact, the first 3 digits cannot be 000 , but they can be 001 , 010 , etc. - Wiktor Stribi偶ew
  • Yes, with the regions, too, everything seems to be not easy) can something like [017]?\d{2} stick in - vp_arth
  • And for non-cars, three-digit regions are used? - Fat-Zer
  • Not sure, but why not? Who knows ... - vp_arth
  • And yet, very rarely, once or twice a year, but on the roads there are still cars with Soviet-format numbers: XX-XX aaa and aXXXXaa. - Yaant

I made myself to determine compliance with the Russian SRT.

 /(([袗-携]\d{3}[袗-携]{1,2})(\d{2,3})|(\d{4}[袗-携]{2})(\d{2})|(\d{3}C?D{1,2}\d{3})(\d{2})|([袗-携]{2}\d{3}[袗-携])(\d{2})|([袗-携]\d{4})(\d{2})|(\d{3}[袗-携])(\d{2})|(\d{4}[袗-携])(\d{2}))/i