import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = ">(\\d{4}\\.\\d{1,2}\\.\\d{1,2})<|>(\\d+)<";
final String string = "<table class=\"m_4348561758375603924m_886074067026015045MsoNormalTable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"408\" style=\"width:306.0pt;border-collapse:collapse\">\n"
+ "<tbody>\n"
+ " <tr style=\"height:31.5pt\">\n"
+ " <td width=\"196\" nowrap style=\"width:147.0pt;border:solid windowtext 1.0pt;background:yellow;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><b><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">Date<u></u><u></u></span></b></p>\n"
+ " </td>\n"
+ " <td width=\"212\" nowrap style=\"width:159.0pt;border:solid windowtext 1.0pt;border-left:none;background:yellow;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><b><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">Reset Code<u></u><u></u></span></b></p>\n"
+ " </td>\n"
+ " </tr>\n"
+ " <tr style=\"height:31.5pt\">\n"
+ " <td width=\"196\" nowrap style=\"width:147.0pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><strong><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">2017.8.10<u></u><u></u></span></strong></p>\n"
+ " </td>\n"
+ " <td width=\"212\" nowrap style=\"width:159.0pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><strong><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">123456<u></u><u></u></span></strong></p>\n"
+ " </td>\n"
+ " </tr>\n"
+ " <tr style=\"height:31.5pt\">\n"
+ " <td width=\"196\" nowrap style=\"width:147.0pt;border:solid windowtext 1.0pt;border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><b><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">2017.8.11<u></u><u></u></span></b></p>\n"
+ " </td>\n"
+ " <td width=\"212\" nowrap style=\"width:159.0pt;border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:31.5pt\">\n"
+ " <p class=\"MsoNormal\" align=\"left\" style=\"text-align:left\"><strong><span lang=\"EN-US\" style=\"font-size:24.0pt;font-family:宋体;color:black\">123456<u></u><u></u></span></strong></p>\n"
+ " </td>\n"
+ " </tr>\n"
+ "</tbody>\n"
+ "</table>";
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