public ArrayList<HtmlLink> grabHTMLLinks(final String html){
  ArrayList<HtmlLink> result=new ArrayList<>();
  Matcher matcherTag=patternTag.matcher(html);
  while (matcherTag.find()) {
    String href=matcherTag.group(1);
    String linkText=matcherTag.group(2);
    Matcher matcherLink=patternLink.matcher(href);
    while (matcherLink.find()) {
      String link=matcherLink.group(1);
      HtmlLink obj=new HtmlLink();
      obj.setLink(link);
      obj.setLinkText(linkText);
      result.add(obj);
    }
  }
  return result;
}

public ArrayList < HtmlLink > grabHTMLLinks ( final String html ) { ArrayList < HtmlLink > result = new ArrayList < > ( ) ; Matcher matcherTag = patternTag . matcher ( html ) ; while ( matcherTag . find ( ) ) { String href = matcherTag . group ( 1 ) ; String linkText = matcherTag . group ( 2 ) ; Matcher matcherLink = patternLink . matcher ( href ) ; while ( matcherLink . find ( ) ) { String link = matcherLink . group ( 1 ) ; HtmlLink obj = new HtmlLink ( ) ; obj . setLink ( link ) ; obj . setLinkText ( linkText ) ; result . add ( obj ) ; } } return result ; }
validate html with regular expression
