Get Url From Img Tag : Url « Network « Android






Get Url From Img Tag

 
    
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main{
    public static String getUrlFromImgTag(String imgTag)
    {
      String url = null;
      
    Pattern p = Pattern.compile("src='[^']*'", Pattern.CASE_INSENSITIVE);
    Matcher m = p.matcher(imgTag);
    if (m.find())
    {
      url = imgTag.substring(m.start() + 5, m.end() - 1);
    }
    
    return url;
   }
}

   
  








Related examples in the same category

1.Using Intent to open a URL
2.Process xml document from a Url
3.Suggest Url Provider
4.Showing android:autoLink property, which linkifies things like URLs and phone numbers found in the text.
5.extends ArrayAdapter to create URL history
6.Used to compress URL using the bit.ly service.
7.URL encode and decode
8.Is valid URL
9.Download from URLConnection
10.Request from an URL
11.Returns the contents of the given URL as an array of strings
12.Read from a URL
13.Pull the raw text content of the given URL.
14.Get Video from URL
15.Gets data from URL
16.get Url Response
17.URL Encode Utils
18.Downloads a file given URL to specified destination
19.get Host From Url
20.encode Url
21.decode Url
22.Convert a byte array to a URL encoded string
23.get Url content with max retries
24.get Url By Post
25.Take a base url and a {@link Map} of parameters to build a valid url