import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?s)(?:<td[^<]*>|\\G(?!^))(?:<[^<]+>)?(?!\\s+)([^<]*)(?:<[^<]+>)?";
final String string = "<table class=\"fiche_table_caracter\"><tbody>\n"
+ "<tr>\n"
+ " <td class=\"caracteristique\"><strong>Design</strong></td>\n"
+ " <td>Classique (full tactile)</td>\n"
+ "</tr>\n\n"
+ "<tr>\n"
+ " <td class=\"caracteristique\"><strong>Système d'exploitation (OS)</strong></td>\n"
+ " <td>iOS</td>\n"
+ "</tr>\n"
+ "<tr>\n"
+ " <td class=\"caracteristique\"><strong>Ecran</strong></td>\n"
+ " <td>4,7'' (1334 x 750 pixels)<br />16 millions de couleurs</td>\n"
+ "</tr>\n"
+ "<tr>\n"
+ " <td class=\"caracteristique\"><strong>Mémoire interne</strong></td>\n"
+ " <td>128 Go, 1 Go RAM</td>\n"
+ "</tr>\n"
+ "<tr>\n"
+ " <td class=\"caracteristique\"><strong>Appareil photo</strong></td>\n"
+ " <td>8 mégapixels</td>\n"
+ "</tr>\n"
+ "</tbody>\n"
+ "</table>";
final Pattern pattern = Pattern.compile(regex);
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