0

I want to verify the syntax of a URL. How should I use regexes to test the validity of a URL like www.chaine.com?

1 Answer 1

1

You can do it this way, without regex:

public boolean validateURI(String uri)
{
    try
    {
        new URI(uri);
        return true;
    } catch(Exception e)
    {
        return false; // MalformedURI Exception, is the name I think
    }
}

URL extends URI, you can say, I think...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.