Sample code: String Message="http://indianexpress.com/article/sports/football/mexico-holds-host-brazil-to-0-0-draw-at-world-cup/ http://indianexpress.com/article/sports/cricket/suresh-raina-surprised-by-stuart-binnys-performance/ http://indianexpress.com/article/sports/football/fifa-world-cup-every-match-is-like-a-final-for-us-says-andres-iniesta/" ArrayList<String> forrmatted=pullLinks(Message); for(int i=0;i<forrmatted.size();i++){ String temp=forrmatted.get(i).toString(); Message=Message.replace(temp, "["+temp+"]"); } private ArrayList<String> pullLinks(String text) { ArrayList<String> links = new ArrayList<String>(); String regex = "\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(text); while(m.find()) { String urlStr = m.group(); ...
Android tutorials, Kotlin tutorials