How to verify if a String in Java is a valid URL

Viewed 90523

How can I check if a string is a URL in Java?

8 Answers
^(https://|http://|ftp://|ftps://)(?!-.)[^\\s/\$.?#].[^\\s]*$

This is a regex to validate URL for protocols http, https, ftp and ftps.

Related