我需要验证增值税号。
xxxx.xxx.xxx --> 0123.456.789 是一个有效的数字。
我找到了一个正则表达式
^(BE)[0-1]{1}[0-9]{9}$|^((BE)|(BE ))[0-1]{1}(\d{3})([.]{1})(\d{3})([.]{1})(\d{3})
这会验证以下条目:BE 0123.456.789。
但我需要的是只验证 xxxx.xxx.xxx(没有别的有效,只有这个)
所以 4 位数字,一个点,3 位数字,一个点,3 位数字。
还需要以0或1开头(first x --> 0 or 1)
最佳答案
给你:
^[01]\d{3}\.\d{3}\.\d{3}$
分割:
^ - Start of string
[01] - Followed by a 0 or 1
\d{3} - Followed by three numerals
\. - Followed by a .
\d{3} - Followed by three numerals
\. - Followed by a .
\d{3} - Followed by three numerals
$ - Followed by end of string
关于javascript - xxxx.xxx.xxx 的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5889310/