I donβt think there is a built-in method or class that you can use to validate a string as a legal url. But you can use a regular expression, something like ["^ a-zA-Z0-9 -._"] +. ([A-zA-Z] [a-zA-Z]) If you use the code from Ranhiru, you will not get it correctly, for example, bild.de and s.int, which are valid URLs.