1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
String codeHTML = getIpFrom("http://www.google.com");
Pattern regex_masque;
Matcher regex_resultat;
//System.out.println(codeHTML);
regex_masque = Pattern.compile("(<a.*href=[\"']([^\"]*)[\"'].*>)",Pattern.CASE_INSENSITIVE);
regex_resultat = regex_masque.matcher(codeHTML);
System.out.println("Nombre de résultat(s) : " + regex_resultat.groupCount());
while(regex_resultat.find()) {
System.out.println("Le texte : " + regex_resultat.group(1));
System.out.println("Le texte : " + regex_resultat.group(2));
}
}
catch(PatternSyntaxException e){}
} |
Partager