import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<div class=\"(.*?) video-item\">(.*?)href=\"([^\"]*)\"(.*?)data-get-thumbs-url=\"([^\"]*)\"(.*?)alt=\"([^\"]*)\"(.*?)src='([^']*)'(.*?)<div class=\"timer hidden-xs\">(\\s*)<p>([0-9]*)(.*?)<\\/p><\\/div>(.*?)<div class=\"description\">(\\s*)<p>(.*?)<\\/p>(.*?)<p class=\"title-video\">(.*?)<\\/p>(.*?)<div class=\"infos-video\">(.*?)<p>Le ([0-9][0-9])\\/([0-9][0-9])\\/([0-9][0-9][0-9][0-9])<\\/p>(\\s*)<p>([0-9 ]*?)vues<\\/p>(.*?)<\\/div>(.*?)<div class=\"cat-video\">(\\s*)(.*?)(\\s*)<\\/div>(\\s*?)<\\/div>";
final String string = "\n"
+ " \n"
+ " <div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">\n\n"
+ " <a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1983/sandrine-teste-la-double.html\">\n"
+ " <div class=\"thumb-video\">\n"
+ " \n"
+ " <img class=\"videoThumb\"\n"
+ " data-get-thumbs-url=\"/video/1983/thumbnails_262x196.json\"\n"
+ " alt=\"Double pénétration, Double vaginale, Sodomie\"\n"
+ " src='http://m.tv2.cdn.jetm-tech.net/cache/4a/c5/4ac5ff7ae42612bfc68139740700ea0c.jpg'\n"
+ " />\n"
+ " \n"
+ " <div class=\"timer hidden-xs\"> <p>47 min</p></div>\n\n"
+ " <div class=\"description\">\n"
+ " <p>Notre équipe retrouve Sandrine devant le château de Blois pour constater, une fois de plus, que cette timide historienne de 31ans est une sacrée chaudasse ! \n"
+ "…</p>\n"
+ " </div>\n"
+ " </div>\n\n"
+ " <p class=\"title-video\"> Sandrine teste la double !</p>\n"
+ " <div class=\"infos-video\">\n"
+ " <p>Le 12/10/2015</p>\n"
+ " <p>1 876 156 vues</p>\n"
+ " </div>\n"
+ " </a>\n"
+ " <div class=\"cat-video\">\n"
+ " <p>Catégories : <a href=\"/tag/1/double-penetration.html\">Double pénétration</a>, <a href=\"/tag/2/double-vaginale.html\">Double vaginale</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a></p>\n"
+ " </div>\n\n"
+ " </div>\n"
+ " \n"
+ " <div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">\n\n"
+ " <a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1982/soizic-passe-un-entretien-dembauche.html\">\n"
+ " <div class=\"thumb-video\">\n"
+ " \n"
+ " <img class=\"videoThumb\"\n"
+ " data-get-thumbs-url=\"/video/1982/thumbnails_262x196.json\"\n"
+ " alt=\"Cougar, Scénario, Sodomie\"\n"
+ " src='http://m.tv2.cdn.jetm-tech.net/cache/cc/e5/cce55a7502d51aaefc049ee83334653c.jpg'\n"
+ " />\n"
+ " \n"
+ " <div class=\"timer hidden-xs\"> <p>30 min</p></div>\n\n"
+ " <div class=\"description\">\n"
+ " <p>Quand Soizic, 40ans, de Saint-Malo, et l'ami Rick se font un petit plan un brin pervers...\n"
+ "Pour voir ses vidéos, mettez Soizic dans la recherche.\n"
+ "Parlez en …</p>\n"
+ " </div>\n"
+ " </div>\n\n"
+ " <p class=\"title-video\"> Soizic passe un entretien d'embauche !</p>\n"
+ " <div class=\"infos-video\">\n"
+ " <p>Le 11/10/2015</p>\n"
+ " <p>1 882 538 vues</p>\n"
+ " </div>\n"
+ " </a>\n"
+ " <div class=\"cat-video\">\n"
+ " <p>Catégories : <a href=\"/tag/23/cougar.html\">Cougar</a>, <a href=\"/tag/56/scenario.html\">Scénario</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a></p>\n"
+ " </div>\n\n"
+ " </div>\n"
+ " \n"
+ " <div class=\"col-md-3 col-sm-4 col-xs-6 video-item\">\n\n"
+ " <a target=\"_blank\" data-popunder-enabled href=\"/videos/show/1981/lola-se-libere.html\">\n"
+ " <div class=\"thumb-video\">\n"
+ " \n"
+ " <img class=\"videoThumb\"\n"
+ " data-get-thumbs-url=\"/video/1981/thumbnails_262x196.json\"\n"
+ " alt=\"Double pénétration, Sodomie, Trio HHF\"\n"
+ " src='http://m.tv2.cdn.jetm-tech.net/cache/f3/5b/f35b23b16f81588dda16702cec5ef284.jpg'\n"
+ " />\n"
+ " \n"
+ " <div class=\"timer hidden-xs\"> <p>42 min</p></div>\n\n"
+ " <div class=\"description\">\n"
+ " <p>Sa première vidéo a eu de telles vertus thérapeutiques que Lola surmonte désormais tous ses complexes et va même jusqu'à nous entraîner chez un de ses nouveaux…</p>\n"
+ " </div>\n"
+ " </div>\n\n"
+ " <p class=\"title-video\"> Lola se libère !</p>\n"
+ " <div class=\"infos-video\">\n"
+ " <p>Le 10/10/2015</p>\n"
+ " <p>1 717 096 vues</p>\n"
+ " </div>\n"
+ " </a>\n"
+ " <div class=\"cat-video\">\n"
+ " <p>Catégories : <a href=\"/tag/1/double-penetration.html\">Double pénétration</a>, <a href=\"/tag/8/sodomie.html\">Sodomie</a>, <a href=\"/tag/21/trio-hhf.html\">Trio HHF</a></p>\n"
+ " </div>\n\n"
+ " </div>\n";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(string);
if (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