Java Regex URL Validate isUrl(String s)

Here you can find the source of isUrl(String s)

Description

is Url

License

Apache License

Declaration

public static boolean isUrl(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    public static boolean isUrl(String s) {
        if (isEmpty(s))
            return false;
        boolean ret = Pattern.matches("^(https|http|ftp|rtsp|mms)?:\\/\\/[^\\s]*$", s);
        if (!ret)
            ret = Pattern.matches("^[\\.\\/\\?#a-zA-Z0-9-_=&;,%]*$", s);
        return ret;
    }//from   ww w. j  a va 2  s  . co m

    public static boolean isEmpty(String str) {
        return str == null || (str.trim().length() == 0);
    }
}

Related

  1. isUri(String input)
  2. isUrl(final String url)
  3. isUrl(String aUrl)
  4. isURL(String f)
  5. isUrl(String s)
  6. IsUrl(String str)
  7. isUrl(String test)
  8. isUrl(String text)