javascript - xxxx.xxx.xxx 的正则表达式

标签 javascript asp.net regex

我需要验证增值税号。

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/

相关文章:

c# - 回发或回调参数无效。单击按钮

php - 删除换行符和空格

regex - sed - 注释与特定字符串匹配且尚未注释掉的行

python - 我应该如何在不考虑 Python 顺序的情况下查找日期和时间?

javascript - 如何使用 Angular JS 访问 HTML 中的 Javascript 对象?

javascript - 需要 Sequence .css() For multi div

javascript - 如何使 Canvas 上的对象在移动设备上顺畅地左右移动到 x 轴

c# - 网页与COM口对接控制页面

javascript - 数组在 res.json() 中为空,但在 res.json() 调用之前和之后都存在

javascript - 在提交时更改目标页面的 css 属性