Phone 数字的正则表达式,不包括小数

Regular Expression for Phone Number and excludes decimal numbers

我使用这个正则表达式来识别我的应用程序中的 phone 数字。 “\\+?\\d{7,23}” 但这不能排除像3.1415926这样的小数。

如何修改这个正则表达式,让它可以识别 phone 数字,而不给我像 3.1415926、99.9999999 这样的小数。

在这种情况下,'1415926' 和 '9999999' 将被识别为 phone 号码,这是不需要的。

一句话,我想拒绝带'.'的数字被部分识别为 phone 数字。或者 phone 数字不应该以“.”作为后缀。或关注 '.'.

谢谢。

最后,我用

解决了这个问题

试试这个正则表达式:

^\+?((?!\.)\d){7,23}$

解释:

\+                string starts with an optional +
((?!\.)\d){7,23}  negative lookahead asserts that string contains between 7 and 23
                  numbers, each of which is not a dot

此处演示:

Regex101