Here you can find the source of extracURL(String _str)
public static String extracURL(String _str)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; import android.text.TextUtils; public class Main { public static String extracURL(String _str) { if (TextUtils.isEmpty(_str)) return ""; // Tip: add a space to the end of original string String str = _str.trim() + " "; // javascript && file: not allowed if (str.matches("^\\w+script:") || str.matches("^file:\\/\\/\\/.+")) return ""; Pattern regex = Pattern.compile("(https?://.+?)[\\s'\"<>\\[\\]]"); Matcher matcher = regex.matcher(str); if (matcher.find()) { return matcher.group(1); } else {//from www .ja v a2 s . c o m return ""; } } }