import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<div\\s[\\s\\S]*?\\\"detailBulletsWrapper_feature_div[\\s\\S]*?<div\\s[\\s\\S]*?detailBullets_feature_div[\\s\\S]*?<ul[\\s\\S]*?ASIN:[\\s\\S]*?<\\/span>\\s*<span>([\\s\\S]*?)<\\/span>";
final String string = "<div id=\"detailBulletsWrapper_feature_div\" data-feature-name=\"detailBullets\" data-template-name=\"detailBullets\" class=\"a-section a-spacing-none feature\" data-cel-widget=\"detailBulletsWrapper_feature_div\">\n"
+ " <div id=\"detailBullets_feature_div\">\n"
+ " \n"
+ " \n\n\n\n\n\n"
+ " <ul class=\"a-unordered-list a-nostyle a-vertical a-spacing-none\">\n"
+ " \n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " <span class=\"a-text-bold\">Product Dimensions:\n"
+ " </span>\n"
+ " <span>5 x 5 x 0.7 inches</span>\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " <span class=\"a-text-bold\">Shipping Weight:\n"
+ " </span>\n"
+ " <span>12 ounces (<a href=\"https://www.amazon.com/gp/help/seller/shipping.html/ref=dp_pd_shipping?_encoding=UTF8&seller=&asin=B07F9GS3VY\">View shipping rates and policies</a>)</span>\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " <span class=\"a-text-bold\">ASIN:\n"
+ " </span>\n"
+ " <span>B07F9GS3VY</span>\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " <span class=\"a-text-bold\">Item model number:\n"
+ " </span>\n"
+ " <span>WXAGLHP2</span>\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " \n"
+ " <span class=\"a-text-bold\">Date first listed on Amazon:\n"
+ " </span>\n"
+ " <span>September 11, 2013</span>\n"
+ " \n"
+ " </span></li>\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " </ul>\n\n\n"
+ " \n"
+ " </div>\n"
+ " \n"
+ " \n\n"
+ "<div id=\"dpx-amazon-sales-rank_feature_div\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
+ "<style type=\"text/css\">\n"
+ ".zg_hrsr_item {list-style : none};\n"
+ "</style>\n"
+ "<li id=\"SalesRank\" style=\"list-style : none\">\n"
+ "<b>Amazon Best Sellers Rank:</b> #36,542 in Clothing, Shoes & Jewelry (<a href=\"https://www.amazon.com/gp/bestsellers/fashion/ref=pd_dp_ts_fashion_1\">See Top 100 in Clothing, Shoes & Jewelry</a>) <style type=\"text/css\">.zg_hrsr { margin: 0; padding: 0; list-style-type: none; }.zg_hrsr_item { margin: 0 0 0 10px; }.zg_hrsr_rank { display: inline-block; width: 80px; text-align: right; }</style><ul class=\"zg_hrsr\"> <li class=\"zg_hrsr_item\"> <span class=\"zg_hrsr_rank\">#39</span> <span class=\"zg_hrsr_ladder\">in <a href=\"https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_1_1\">Clothing, Shoes & Jewelry</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_1_2\">Women</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_1_3\">Shoes</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_1_4\">Athletic</a> > <b><a href=\"https://www.amazon.com/gp/bestsellers/fashion/679351011/ref=pd_zg_hrsr_fashion_1_5_last\">Women's</a></b></span> </li> <li class=\"zg_hrsr_item\"> <span class=\"zg_hrsr_rank\">#129</span> <span class=\"zg_hrsr_ladder\">in <a href=\"https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_2_1\">Clothing, Shoes & Jewelry</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_2_2\">Women</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_2_3\">Shoes</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_2_4\">Athletic</a> > <b><a href=\"https://www.amazon.com/gp/bestsellers/fashion/679377011/ref=pd_zg_hrsr_fashion_2_5_last\">Walking</a></b></span> </li> <li class=\"zg_hrsr_item\"> <span class=\"zg_hrsr_rank\">#284</span> <span class=\"zg_hrsr_ladder\">in <a href=\"https://www.amazon.com/gp/bestsellers/fashion/ref=pd_zg_hrsr_fashion_3_1\">Clothing, Shoes & Jewelry</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/7147440011/ref=pd_zg_hrsr_fashion_3_2\">Women</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/679337011/ref=pd_zg_hrsr_fashion_3_3\">Shoes</a> > <a href=\"https://www.amazon.com/gp/bestsellers/fashion/6127771011/ref=pd_zg_hrsr_fashion_3_4\">Athletic</a> > <b><a href=\"https://www.amazon.com/gp/bestsellers/fashion/679360011/ref=pd_zg_hrsr_fashion_3_5_last\">Women's</a></b></span> </li></ul>\n"
+ "</li>\n"
+ "</div>\n\n"
+ " \n"
+ " <ul class=\"a-unordered-list a-nostyle a-vertical a-spacing-none\">\n"
+ " \n"
+ " <li><span class=\"a-list-item\">\n"
+ " <span class=\"a-text-bold\">\n"
+ " Average Customer Review:\n"
+ " </span>\n"
+ " \n\n\n\n\n"
+ "<style type=\"text/css\">\n"
+ " /* \n"
+ " * Fix for UDP-1061. Average customer reviews has a small extra line on hover \n"
+ " * https://omni-grok.amazon.com/xref/src/appgroup/websiteTemplates/retail/SoftlinesDetailPageAssets/udp-intl-lock/src/legacy.css?indexName=WebsiteTemplates#40\n"
+ " */\n"
+ " .noUnderline a:hover { \n"
+ " text-decoration: none; \n"
+ " }\n"
+ "</style>\n\n\n\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n\n"
+ " \n\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n\n"
+ " <div id=\"detailBullets_averageCustomerReviews\" class=\"a-spacing-none\" data-asin=\"B07F9GS3VY\" data-ref=\"dpx_acr_pop_\">\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n\n\n\n\n\n\n\n\n\n\n"
+ " <span class=\"a-declarative\" data-action=\"acrStarsLink-click-metrics\" data-acrstarslink-click-metrics=\"{}\">\n"
+ " \n\n\n\n\n\n"
+ " <span id=\"acrPopover\" class=\"reviewCountTextLinkedHistogram noUnderline\" title=\"4.1 out of 5 stars\">\n"
+ " <span class=\"a-declarative\" data-action=\"a-popover\" data-a-popover=\"{"max-width":"700","closeButton":"false","position":"triggerBottom","url":"/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=B07F9GS3VY"}\">\n"
+ " <a href=\"javascript:void(0)\" class=\"a-popover-trigger a-declarative\">\n"
+ " \n\n"
+ "<i class=\"a-icon a-icon-star a-star-4\"><span class=\"a-icon-alt\">4.1 out of 5 stars</span></i>\n"
+ " \n"
+ " <i class=\"a-icon a-icon-popover\"></i></a>\n"
+ " </span>\n"
+ " <span class=\"a-letter-space\"></span>\n"
+ " </span>\n\n\n"
+ " </span>\n"
+ " <span class=\"a-letter-space\"></span>\n"
+ " \n"
+ " \n\n"
+ " \n\n"
+ " \n\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " <span class=\"a-declarative\" data-action=\"acrLink-click-metrics\" data-acrlink-click-metrics=\"{}\">\n"
+ " <a id=\"acrCustomerReviewLink\" class=\"a-link-normal\" href=\"#customerReviews\">\n"
+ " <span id=\"acrCustomerReviewText\" class=\"a-size-base\">221 customer reviews</span>\n"
+ " </a>\n"
+ " </span>\n"
+ " \n"
+ " <script type=\"text/javascript\">\n"
+ " P.when('A', 'ready').execute(function(A) {\n"
+ " A.declarative('acrLink-click-metrics', 'click', { \"allowLinkDefault\" : true }, function(event){\n"
+ " if(window.ue) {\n"
+ " ue.count(\"acrLinkClickCount\", (ue.count(\"acrLinkClickCount\") || 0) + 1);\n"
+ " }\n"
+ " });\n"
+ " });\n"
+ " </script>\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " <script type=\"text/javascript\">\n"
+ " P.when('A', 'cf').execute(function(A) {\n"
+ " A.declarative('acrStarsLink-click-metrics', 'click', { \"allowLinkDefault\" : true }, function(event){\n"
+ " if(window.ue) {\n"
+ " ue.count(\"acrStarsLinkWithPopoverClickCount\", (ue.count(\"acrStarsLinkWithPopoverClickCount\") || 0) + 1);\n"
+ " }\n"
+ " });\n"
+ " });\n"
+ " </script>\n\n\n"
+ " \n"
+ " \n"
+ " </div>\n"
+ " \n\n\n"
+ " </span></li>\n"
+ " \n"
+ " </ul>\n"
+ " <div class=\"a-row\">\n"
+ " \n"
+ " \n\n\n\n\n"
+ " \n"
+ " </div>\n"
+ " <div class=\"a-row\">\n"
+ " \n"
+ " \n\n\n\n\n\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " If you are a seller for this product, would you like to <b><a href=\"https://sellercentral.amazon.com/cu/contact-us?categoryId=30002&typeId=30005\">suggest updates through seller support</a></b>?\n\n\n"
+ " \n"
+ " </div>\n"
+ "</div>";
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