Portuguese Vehicle plate structural verification

倖福魔咒の 提交于 2019-12-25 18:53:21

问题


I want to validate if a plate of a Portuguese car has a valid structure.

Portuguese Plate is XX-XX-XX alpha numeric. It's Alpha numeric but you can´t have a number and a Char on the same position Example :

A5-99-AB -> It's wrong

55-99-AB -> it's right

Although there are sequences that are not yet valid according to PT plate rules (e.g 2 sets of letters AA-00-AA) this is something that I do not pretend to validate since it changes often.


回答1:


Try

let re = /^([A-Z]{2}|\d\d)-([A-Z]{2}|\d\d)-([A-Z]{2}|\d\d)$/;

console.log( re.test('A5-99-AB') );
console.log( re.test('55-99-AB') );


来源:https://stackoverflow.com/questions/58993381/portuguese-vehicle-plate-structural-verification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!