且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用正则表达式检查整个字符串

更新时间:2021-12-25 22:03:30

\d+ 匹配字符串的任意正数位数,因此它匹配第一个 78 并成功.

\d+ matches any positive number of digits within your string, so it matches the first 78 and succeeds.

使用^\d+$.

或者,更好:"78.46.92.168:8000".isdigit()