import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?si)(?<=<span style=\"font-size: 16px; font-family: Arial;\">)(?!.*?(?:strong|contenuto)).*? <\\/span><br>.*?(?=<\\/span><br>\\s+<br>)";
final String string = "<p data-mce-style=\"margin-top: 5.0pt; margin-right: 1.5pt; margin-bottom: 5.0pt; margin-left: 37.55pt; mso-pagination: widow-orphan;\" style=\"margin: 5pt 1.5pt 5pt 37.55pt; text-align: center;\"><br>\n"
+ "</p>\n"
+ "<p style=\"text-align: center;\">\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\"><strong>Caratteristiche:</strong></span><br>\n"
+ "<br>\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\"> Contenuto del\n"
+ "pacco:</span><br>\n"
+ "<br>\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\">PC empire , usato perfettamente funzionante con windows 10 anche se ha coa windows 7 originale \n"
+ "con lettore di schede di memoria mmc e altri formati con 8 porte usb 2.00 , con processore i5 -2400 e 8gb di ram\n"
+ "500 gb di hardisk e lettore masterizzatore dvd scheda lan on board e scheda video e audio onboard \n"
+ "windows 10 64 bit appena installato , perfettamente funzionante </span><br>\n"
+ "<br>\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\"> \n"
+ "l'acquisto e' fatto come visto e piaciuto\n"
+ "le immagini descrivono i prodotti e le condizioni dei tali\n"
+ "le descrizioni dei prodotti sono puramente indicative. \n"
+ "Per ottenere una descrizione accurata si consiglia di visitare il sito del produttore.\n"
+ "non rispondiamo di eventuali differenze riscontrabili tra le caratteristiche indicate nelle descrizioni e le immagini</span><br>\n"
+ "<br>\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\"> \n\n\n"
+ "</span><br>\n"
+ "<br>\n"
+ "<span style=\"font-size: 16px; font-family: Arial;\"><span style=\"color: rgb(255, 51, 51);\"> </span><br>\n"
+ "</span> </p>\n"
+ "<p style=\"text-align: center;\"><span style=\"font-size: 16px; font-family: Arial;\"><br>\n"
+ "</span> </p>\n"
+ "<p style=\"text-align: center;\"><span style=\"font-size: 16px; font-family: Arial;\"><br>\n"
+ "</span> </p>";
final Pattern pattern = Pattern.compile(regex, 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