import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<script.*src.*edge.*<\\/script>";
final String string = "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>\n"
+ " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"
+ " <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\"/>\n"
+ " <title>Untitled</title>\n"
+ "<!--Adobe Edge Runtime-->\n"
+ " <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\">\n"
+ " <script src=\"//ad.adverticum.net/scripts/goa-helper.js\"></script>\n"
+ " <script type=\"text/javascript\" charset=\"utf-8\" src=\"http://animate.adobe.com/runtime/5.0.0/edge.5.0.0.min.js\"></script>\n"
+ " <style>\n"
+ " .edgeLoad-EDGE-20744748 { visibility:hidden; }\n"
+ " </style>\n"
+ "<script>\n"
+ " AdobeEdge.loadComposition('MM_Gyor_Huawei_1112-1114_HTML5_720x250', 'EDGE-20744748', {\n"
+ " scaleToFit: \"none\",\n"
+ " centerStage: \"both\",\n"
+ " minW: \"0\",\n"
+ " maxW: \"undefined\",\n"
+ " width: \"720px\",\n"
+ " height: \"250px\"\n"
+ "}, {\"dom\":{}}, {\"dom\":{}});\n"
+ "</script>\n"
+ "<!--Adobe Edge Runtime End-->\n\n"
+ "</head>\n"
+ "<body style=\"margin:0;padding:0;\">\n"
+ " <div id=\"Stage\" class=\"EDGE-20744748\"></div>\n"
+ " \n"
+ "</body>\n"
+ "</html>";
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