4

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

Thanks

4

1 回答 1

4

要匹配href属性值,您可以使用以下方法:

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);
}
于 2012-05-21T18:46:08.097 回答