Checking whole string with a regex

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

Use ^\d+$.

Or, even better: "78.46.92.168:8000".isdigit()

Leave a Comment