Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; import android.util.Patterns; public class Main { public static String firstUrl(String text) { if (!TextUtils.isEmpty(text)) for (String s : text.split("\\s+")) if (Patterns.WEB_URL.matcher(s).matches()) return s; return null; } }