This is the first day of my participation in Gwen Challenge
The re verifies the license plate number
In my work, I often encounter the situation of verifying license plate numbers. There are also a large number of verification methods on the Internet, but most of them cannot verify new energy license plates. Go straight to the latest code
Function isLicensePlate (STR) {return / ^ (([beijing-tianjin Shanghai yu ji yu cloud liao black xiang anhui new GuiGan of hubei province can Sue your yue jin meng shan ji min qinghai-tibet plain NingQiong make led] [a-z] ([[0-9] {5} [DF]) | ([DF], [A - HJ - NP - Z0-9]] [0-9] {4}))) | ([the Beijing and tianjin only black new xiang wan lu su liao ji yu cloud of hubei province can GuiGan jin meng shan ji min expensive Guangdong qinghai-tibet plain NingQiong make led] [a-z] [A - HJ - NP - Z0-9] {4} [A - HJ - NP - Z0 - hang cop Hong Kong and Macao to bring]) $/. The test (STR); }Copy the code
License plate Verification Rules
1, the traditional license plate First bit of provinces (Chinese characters), the second for the licensing authority code (letters a-z) for the serial number of 3 to 7 (composed of letters or Numbers, but there is no letters I and O, prevent and confused the number 1, 0, and the last is likely to be “hung cop Hong Kong and Macao to make collar” one of the Chinese characters).
2. The first and second spots of the new energy license plate are the same as those of the traditional license plate, and the third to eighth spots are serial numbers (one more than the traditional license plate). The serial number rules for new energy license plates are as follows: Small cars: the first digit can only be a letter D or F, the second digit can be a number or letter, and the third to sixth digit must be a number. Large cars: digits 1 through 5 must be numbers, and digits 6 must be letters D or F only.
The test shows that
I also found the regular verification written by others on the Internet before, but there are bugs, so I wrote the above regular verification. Whether you wrote your own license plate or found it online, you can test it with the license plate below to see if it’s correct. Correct license plate: Chuan A123AB, Chuan A2222 Xue, Chuan AF12345, Chuan A12345D. Wrong license plate: Chuan A123456, Chuan A2222i, Chuan AA12345, Chuan AD123456.