Want a regex for validating Indian Vehicle Number Format?

前端 未结 11 944
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 21:35

Hello everyone here...

I need to build up a swing application related to vehicle registration and in which i want to do input the vehicle number of indian standard, like

11条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 22:05

    Try this

    ^[A-Z]{2}\s[0-9]{2}\s[A-Z]{2}\s[0-9]{4}$
    

    ^ means start of string
    [A-Z]{2} means 2 characters in the range of A through Z
    \s means white space
    [0-9]{2} means 2 characters in the range of 0 through 9
    \s means white space
    [A-Z]{2} means 2 characters in the range of A through Z
    \s means white space
    [0-9]{4} means 4 characters in the range of 0 through 9
    $ means end of string

    Based on what you said in your question this should be a very broad check against proper format, but I have a feeling that there are more specific regulations on how the license plates are numbered. Let me know if there are additional constraints for the regex.

提交回复
热议问题