用于驾驶执照验证的正则表达式模式
Regex pattern for Driving Licence validation
我正在尝试编写一个正则表达式模式,它应该允许以下格式的安大略省驾驶执照
要求:正则表达式应该是任意字母后跟14位数字,可以有
字母和数字之间或这 14 位数字之间的 1 个或多个特殊字符
- D6101-40706-60905
- D6101 40706 60905
- D61014070660905
A1234 - 12345 - 12345
不允许以下模式:即包含或不包含非 space 字符的 14 个以上数字。
D6101 40706 609053
- D6101070660905313
正则表达式:^[A-Za-z][0-9/\W/]{2,20}$
您可以使用正则表达式
^[A-Z](?:\d[- ]*){14}$
正则表达式引擎执行以下操作。
^ # match beginning of line
[A-Z] # match a capital letter
(?: # begin a non-cap grp
\d # match a digit
[- ]* # match a hypthen or space 0+ times
) # end non-cap grp
{14} # execute non-cap grp 14 times
$ # match end of line
希望这对您有所帮助
/d
// 这代表任何一个数字[0-9]
/w
// 代表任何一个词
//if you wanted to repeat this 14 times you could add curly braces and the number inside
/^(\d{14})$/
"^(([A-Z]{2}[0-9]{2})( )|([A-Z]{2}-[0-9]{2}))((19|20)[0-9][0-9])[0-9]{7}" +
"|([a-zA-Z]{2}[0-9]{2}[\/][a-zA-Z]{3}[\/][0-9]{2}[\/][0-9]{5})" +
"|([a-zA-Z]{2}[0-9]{2}(N)[\-]{1}((19|20)[0-9][0-9])[\-][0-9]{7})" +
"|([a-zA-Z]{2}[0-9]{14})" +
"|([a-zA-Z]{2}[\-][0-9]{13})$"
这将验证几乎所有具有最新编号模式的印度各州驾驶执照。
我正在尝试编写一个正则表达式模式,它应该允许以下格式的安大略省驾驶执照
要求:正则表达式应该是任意字母后跟14位数字,可以有 字母和数字之间或这 14 位数字之间的 1 个或多个特殊字符
- D6101-40706-60905
- D6101 40706 60905
- D61014070660905
A1234 - 12345 - 12345
不允许以下模式:即包含或不包含非 space 字符的 14 个以上数字。
D6101 40706 609053
- D6101070660905313
正则表达式:^[A-Za-z][0-9/\W/]{2,20}$
您可以使用正则表达式
^[A-Z](?:\d[- ]*){14}$
正则表达式引擎执行以下操作。
^ # match beginning of line
[A-Z] # match a capital letter
(?: # begin a non-cap grp
\d # match a digit
[- ]* # match a hypthen or space 0+ times
) # end non-cap grp
{14} # execute non-cap grp 14 times
$ # match end of line
希望这对您有所帮助
/d
// 这代表任何一个数字[0-9]
/w
// 代表任何一个词
//if you wanted to repeat this 14 times you could add curly braces and the number inside
/^(\d{14})$/
"^(([A-Z]{2}[0-9]{2})( )|([A-Z]{2}-[0-9]{2}))((19|20)[0-9][0-9])[0-9]{7}" +
"|([a-zA-Z]{2}[0-9]{2}[\/][a-zA-Z]{3}[\/][0-9]{2}[\/][0-9]{5})" +
"|([a-zA-Z]{2}[0-9]{2}(N)[\-]{1}((19|20)[0-9][0-9])[\-][0-9]{7})" +
"|([a-zA-Z]{2}[0-9]{14})" +
"|([a-zA-Z]{2}[\-][0-9]{13})$"
这将验证几乎所有具有最新编号模式的印度各州驾驶执照。