Consider a regex for testing port numbers.
(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3})
This is not valid in Android.
Any idea what a port number regex should look like in Android?
Consider a regex for testing port numbers.
(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3})
This is not valid in Android.
Any idea what a port number regex should look like in Android?
"(6553[0-5]|655[0-2]\\d|65[0-4]\\d{2}|6[0-4]\\d{3}|[1-5]\\d{4}|[1-9]\\d{0,3})"
works on a Java Regex test page assuming that you are writing Java code. You probably have to escape the backslashes for the Java string literal to work. However, this expression does not thing that zero is a valid port number.
Generally, regex isn't that great for numerical validation. I'd recommend using Integer.parseInt
on a matched group and then check that to see if it's less than 65536.