Possible Duplicates:
What is the best regular expression to check if a string is a valid URL
Java-How to detect the presence of URL in a string.
Is there a way to see if a string is a valid URL? I'm using MIDP library and there are not regular expressions in MIDP. Any help is greatly appreciated.
Why not just construct a java.net.URL
out of the string and catch any exceptions that might be thrown?
String something;
try {
URL url = new URL(something);
} catch (MalformedURLException e) {
// it wasn't a URL
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With