Good day! I ask for help from people who more or less know regular expressions.

It is necessary to check the text so that it is like this 袗000袗袗000 (letters in Cyrillic)

Ie, it can be A123BN999 , etc. 0 - digit A - a letter in Cyrillic

This, by the way, check the license plate number

Help please, I will be very grateful!

I am writing in Python3

  • one
    "^[袗-携]\d{3}[袗-携]{2}\d{2,3}$" ? - MaxU
  • @MaxU Thank you !! - Milkiweed Gtlt
  • one
    Pointers of the beginning and end of the line are forgotten. - Visman
  • If these are Russian numbers, then in theory additional conditions are needed. In particular, not all letters are used (for example, the same "I" cannot be), there are also no numbers with three zeros. - Yaant
  • @Yaant thanks, I would at least some first; D - Milkiweed Gtlt

1 answer 1

From Wikipedia:

Combinations on standard license plates are based on the principle - 3 letters, 3 numbers. The letters mean a series of license plate, and the numbers - the number. GOST for use on characters allowed 12 Cyrillic letters, which have graphic analogs in the Latin alphabet - A, B, E, K, M, H, O, P, C, T, U and X.

 ^[袗袙袝袣袦袧袨袪小孝校啸]\d{3}[袗袙袝袣袦袧袨袪小孝校啸]{2}\d{2,3}$ 

RegEx online

Python example:

 In [22]: pat Out[22]: '^[袗袙袝袣袦袧袨袪小孝校啸]\\d{3}[袗袙袝袣袦袧袨袪小孝校啸]{2}\\d{2,3}$' In [23]: lst Out[23]: ['小065袦袣78', '携001蝎蝎001', '袗001袧袗47'] In [24]: [bool(re.match(pat, txt)) for txt in lst] Out[24]: [True, False, True]