最佳答案
您可以尝试正则表达式:
public static final String URL_REGEX = "^((https?|ftp)://|(www|ftp)\\.)?[a-z0-9-]+(\\.[a-z0-9-]+)+([/?].*)?$";
Pattern p = Pattern.compile(URL_REGEX);
Matcher m = p.matcher("example.com");//replace with string to compare
if(m.find()) {
System.out.println("String contains URL");
}
关于java - Android - 如何验证 url 并添加 http ://www,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33980684/