Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isValidUrl(String input) { String URL_REGEX = "^((https?|ftp)://|(www|ftp)\\.)?[a-z0-9-]+(\\.[a-z0-9-]+)+([/?].*)?$"; Pattern p = Pattern.compile(URL_REGEX); Matcher m = p.matcher(input); if (m.find()) { return true; } return false; } }