Regular expression of vehicle grade check

Source: Internet
Author: User

First, the car grade check rules

1. Regular license plate number: Only the Chinese characters are allowed to start, the following can be entered into six characters, by uppercase English letters and Arabic numerals. such as: Guangdong B12345;
2. Armed Police license plate: Allow the first two uppercase English letters, the following can be entered into five or six characters, the capital of the English alphabet and Arabic numerals, of which the third can record Chinese characters can also record uppercase English letters and Arabic numerals, the third can also be empty, such as: WJ Police 00081, Wj Jing 1234J, wj1234x.
3. The last one for the Chinese character license plate: Allow to start with the Chinese characters, the following can be entered six characters, the first five characters, from uppercase letters and Arabic numerals, and the last character for Chinese characters, Chinese characters include "hanging", "learning", "police", "army", "Hong Kong", "AO". such as: Guangdong Z1234 Port.
4. The Forces Nouvelles license plate: Start with a two-digit uppercase English letter, followed by 5-digit Arabic numerals. such as: BA12345.

Second, the regular expression

^[Jing Jin Hu yu ji yu Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Meng Shan Gi Jingui Guangdong Qinghai-Tibet Kanningjong led a-z]{1}[a-z]{1}[police Beijing-Tianjin-Chongqing-Hebei-Henan Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Mongolia Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong]{0,1}[a-z0-9]{4}[ A-z0-9 Hang School Police Hong Kong and Macao]{1}$

Iii. Examples of Use

1. Oracle PL/SQL

  Create or Replace  functionIs_vehicle_number (P_vehicle_numberinch varchar2)return  Number   isV_result Number; V_expressvarchar2( -); begin    --default 0, indicates incorrectV_result:= 0; V_express:= '^[jing Jin hu yu ji yu Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Meng Shan Gi Jingui Guangdong Qinghai-Tibet Kanningjong led a-z]{1}[a-z]{1}[police Beijing-Tianjin-Chongqing-Hebei-Henan Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Mongolia Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong]{0,1}[a-z0-9]{4}[ A-z0-9 Hang School Police Hong Kong and Macao]{1}$'; ifRegexp_like (P_vehicle_number, v_express) ThenV_result:= 1; End if; returnV_result; End;

2. Javascript

  function Isvehiclenumber (vehiclenumber) {      var express =/^[Beijing-Tianjin-Chongqing-Hebei-Henan-Liaoning-Hunan-Anhui-Shandong-Jiangsu-Zhejiang-Jiangxi-Guiganjin-Shaanxi-Gi Jingui-Qinghai-Tibet Kanningjong-A-z]{1} [A-z] {1} [Police jing Jin Shanghai Yu ji yu Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Mongolian Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong] {0,1} [A-z0-9] {4} [A-z0-9-Hung school police, Hong Kong and Macao] {1}$/;       return express.test (Vehiclenumber);  }

3.c#

 Public Static BOOL Isvehiclenumber (string  vehiclenumber) {    string@ "^[ BEIJING-Tianjin-Shanghai-Chongqing-Hebei-Henan-Liaoning-Hunan-Anhui-Shandong-Jiangsu-Zhejiang-Jiangxi-Guiganjin-Gi Jingui-Guangdong-Qinghai-Tibet Kanningjong-a-z]{1}[a-z]{1}[police Beijing-Tianjin-Shanghai-Chongqing-Hebei-Henan-Liaoning-Hunan-Anhui-Shandong-Jiangsu-Jiangxi-Hubei-Guiganjin-Shaanxi-Xizang-Tibet-Gi Jingui-Hung-hong ]{1}$";     return Regex.IsMatch (Vehiclenumber, Express);}

Iii. references
JS Calibration Car Grade
Special licences for license plates

Regular expression of vehicle grade check

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.