List of utility methods to do String to URL Convert
String | getYoutubeId(String url) get Youtube Id String pattern = "https?:\\/\\/(?:[0-9A-Z-]+\\.)?(?:youtu\\.be\\/|youtube\\.com\\S*[^\\w\\-\\s])([\\w\\-]{11})(?=[^\\w\\-]|$)(?![?=&+%\\w]*(?:['\"][^<>]*>|<\\/a>))[?=&+%\\w]*"; Pattern compiledPattern = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); Matcher matcher = compiledPattern.matcher(url); if (matcher.find()) { return matcher.group(1); return null; ... |
String | preUrl(String url) pre Url if (url == null) { return null; if (url.startsWith("http://") || url.startsWith("https://")) { return url; } else { return "http://" + url; |
String | TruncateUrlPage(String strURL) Truncate Url Page String strAllParam = null; String[] arrSplit = null; strURL = strURL.trim().toLowerCase(); arrSplit = strURL.split("[?]"); if (strURL.length() > 1) { if (arrSplit.length > 1) { if (arrSplit[1] != null) { strAllParam = arrSplit[1]; ... |
boolean | isValidUrl(String url) is Valid Url if (isBlank(url)) return false; String strPattern = "^(http|https)://(.+)/(.+)([.]+)(.+)$"; Pattern p = Pattern.compile(strPattern); Matcher m = p.matcher(url); return m.matches(); |
String | imageUrl_2_ImageName(String imageUrl) image Ur Image Name if (imageUrl == null || imageUrl.isEmpty() || !imageUrl.contains("http://")) { return null; int start = imageUrl.lastIndexOf('/'); if (start == -1) { return null; int end = imageUrl.lastIndexOf('.'); if (end == -1) { return null; if (end <= start + 1) { return null; return imageUrl.substring(start + 1, end); |
List | extractUrls(String text) extract Urls List<String> urls = new ArrayList<String>(); Matcher matcher = urlPattern.matcher(text); while (matcher.find()) { urls.add(matcher.group()); return urls; |
boolean | isUrlValid(String str, boolean isCaseSensitve) is Url Valid if (!isCaseSensitve) str = str.toLowerCase(defloc); String regex = "^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*" + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." ... |