SpartanApps
SpartanApps

Reputation: 45

Android regular expression to get links of webpage source

I am looking for a RegEx to match links from a webpage source. If you have any code samples it would be appriciated.

Thanks

Upvotes: 4

Views: 1270

Answers (1)

rekaszeru
rekaszeru

Reputation: 19220

To match href attribute values you can use the following method:

final Pattern pattern = Pattern.compile("href=\"(.*+)\"");
Matcher matcher = pattern.matcher(html);
String link = null;
while (matcher.find())
{
    link = matcher.group(1);
    Log.i("my.regex", "Found link: " + link);
}

Upvotes: 4

Related Questions