我需要正则表达式方面的帮助
我需要它匹配以50.
我有:
^[ ]*(50)[0-9]{7}[ ]*$
Run Code Online (Sandbox Code Playgroud)
允许 9 位数字。
我该如何扩展它以便它也允许 10 位数字?
添加范围 {7,8}
^[ ]*(50)[0-9]{7,8}[ ]*$
Run Code Online (Sandbox Code Playgroud)
仅供参考,该站点描述了您可以在正则表达式中使用的标准量词:
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2579 次 |
| 最近记录: |