import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\<\\!\\-{2})([a-z\\ ]*)(\\-{2}\\>)";
final String string = "<header class=\"noSelect\">\n"
+ " <div id=\"HIAccueil\" class=\"I-B\">\n"
+ " <img class=\"pointer\" src=\"IMG/BACKGROUND/HEADER/logoban.png\" alt=\"Accueil\" onclick=\"clickMenu(tousLesMenus, 2, tousLesMenus[0].nom, 1, 0, 0, 0, tousLesMenus[1].url);\">\n"
+ " </div>\n"
+ " <div id=\"HIPC\">\n"
+ " <div id=\"HIProfile\" class=\"I-B\">\n"
+ " <!-- vide pour img via js -->\n"
+ " </div>\n"
+ " <div id=\"HIConnect\" class=\"I-B\">\n"
+ " <img class=\"pointer\" src=\"IMG/BACKGROUND/HEADER/connect_hover.gif\" alt=\"Connect\" onclick=\"clickMenu(tousLesMenus, 5, tousLesMenus[0].nom, 4, 1, 1, 0, tousLesMenus[4].url);\">\n"
+ " </div>\n"
+ " </div>\n"
+ "</header>\n"
+ "Tralloc_Nivek-02.baza_R-d421@gmail45.com\n"
+ "Tralloc_Nivek-02@gmail45.com\n"
+ "Tralloc_Nivek-02.baza_R-d421gmail45.c\n\n"
+ "010/226679\n"
+ "010226679\n"
+ "010/22.66.79\n"
+ "010/22 66 79\n"
+ "0470040747\n"
+ "0470/040747\n"
+ "0470/040.747\n"
+ "0470/04.07.47\n"
+ "0470/04 07 47\n"
+ "0470/040 747\n"
+ "+0032470040747\n"
+ "0032470/040 747\n"
+ "+00320470040747";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html