javascript - Problem validating a phone number beginning with 256 using Javascript
问题描述
I am trying to validate a phone number beginning with 256 and the whole phone number should be a maximum of 12 characters, an example of the phone number is 256732111890 I am using the following regex which seems not to work
^(?:[256]●?){6,14}[0-9]$
解决方案
我将发布模式,在这里解释。
图案:^256\d{9}$
在哪里
^
= 断言行首256
= 匹配字符串 256\d{9}
= 在找到“256”后匹配任意数字 9 次(精确)。$
= 该行必须在找到 9 个数字后结束。
此外,一个很好的选择是^256\d{7,9}$
@Pushpesh Kumar Rajwanshi 发布的谁与我的模式不同:
\d{7,9}
: 在找到 '256' 后匹配 7 到 9 次之间的任何数字。
推荐阅读
- qt - 将 QML 小部件绑定到列表模型,但让某些小部件仅绑定到特定索引?
- sql - 如何添加对多个“标签”的引用?
- html - Flexbox 默认溢出行为概念检查
- java - Instagram graphql 在“edge_hashtag_to_media”中隐藏“count”
- python - 带有减号的字符串传递给python中的函数
- vue.js - 如何在 nuxtjs 中的每个页面更改上运行脚本
- r - 如何在 R 中对直方图数据帧进行 ANOVA 和 Tukey 的 HSD
- c# - 为什么保存文本的淡入/淡出在保存时只淡出一次?
- javascript - Barba.js (v2.9.7) 重新加载当前页面而不是下一个
- python - Python 子类重写了具有不同签名的方法,因此不调用基类方法。这是为什么?