import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\s*\\<title\\>thank you\\<\\/title\\>\\s*\\<meta.{0,50}?outlook\\.office\\.com\\/owa\\/.{0,1500}dl\\.dropboxusercontent\\.com.{0,100}?\\/outlook_cover_.{0,450}?style=\"position:absolute; overflow:hidden.{0,450}?\"ws20\"\\>outlook.com.{0,70}?<\\/html\\>\\s*$";
final String string = "\n"
+ "<title>Thank You</title>\n"
+ "<meta http-equiv=\"refresh\" content=\"5; url=https://outlook.office.com/owa/\">\n"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n\n\n"
+ "<link rel=\"shortcut icon\" href=\"https://dl.dropboxusercontent.com/s/wyagp9nopa1bu80/favicon.ico\">\n"
+ " \n"
+ " \n"
+ " \n\n\n"
+ "</head><body >\n"
+ "<style type=\"text/css\">\n"
+ "/*----------Text Styles----------*/\n"
+ ".ws6 {font-size: 8px;}\n"
+ ".ws7 {font-size: 9.3px;}\n"
+ ".ws8 {font-size: 11px;}\n"
+ ".ws9 {font-size: 12px;}\n"
+ ".ws10 {font-size: 13px;}\n"
+ ".ws11 {font-size: 15px;}\n"
+ ".ws12 {font-size: 16px;}\n"
+ ".ws14 {font-size: 19px;}\n"
+ ".ws16 {font-size: 21px;}\n"
+ ".ws18 {font-size: 24px;}\n"
+ ".ws20 {font-size: 27px;}\n"
+ ".ws22 {font-size: 29px;}\n"
+ ".ws24 {font-size: 32px;}\n"
+ ".ws26 {font-size: 35px;}\n"
+ ".ws28 {font-size: 37px;}\n"
+ ".ws36 {font-size: 48px;}\n"
+ ".ws48 {font-size: 64px;}\n"
+ ".ws72 {font-size: 96px;}\n"
+ ".wpmd {font-size: 13px;font-family: Arial,Helvetica,Sans-Serif;font-style: normal;font-weight: normal;}\n"
+ "/*----------Para Styles----------*/\n"
+ "DIV,UL,OL /* Left */\n"
+ "{\n"
+ " margin-top: 0px;\n"
+ " margin-bottom: 0px;\n"
+ "}\n"
+ "</style>\n\n\n\n"
+ "<div id=\"image1\" style=\"position:absolute; overflow:hidden; left:-1px; top:0px; width:1349px; height:207px; z-index:0\"><img src=\"https://dl.dropboxusercontent.com/s/i8rdyrn4pu42ypv/thankyou.png\" alt=\"\" title=\"\" border=\"0\" width=\"1349\" height=\"207\"></div>\n\n"
+ "<div id=\"image2\" style=\"position:absolute; overflow:hidden; left:57px; top:246px; width:340px; height:191px; z-index:1\"><img src=\"https://dl.dropboxusercontent.com/s/tb8we0sntr8nw6j/outlook_cover_640x360.jpg\" alt=\"\" title=\"\" border=\"0\" width=\"340\" height=\"191\"></div>\n\n"
+ "<div id=\"image3\" style=\"position:absolute; overflow:hidden; left:1111px; top:398px; width:165px; height:162px; z-index:2\"><img src=\"https://dl.dropboxusercontent.com/s/r7gamdlswzq5iwh/hosted-exchange-logo.jpg\" alt=\"\" title=\"\" border=\"0\" width=\"165\" height=\"162\"></div>\n\n"
+ "<div id=\"text1\" style=\"position:absolute; overflow:hidden; left:12px; top:4px; width:556px; height:93px; z-index:3\">\n"
+ "<div class=\"wpmd\">\n"
+ "<div><font color=\"#FFFFFF\" face=\"Gisha\" class=\"ws20\">Outlook.com</font></div>\n"
+ "</div></div>\n\n\n\n\n"
+ "</body></html>";
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
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