import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\b[a-zA-Z]*\\d{5,}[a-zA-Z]*\\b";
final String string = "Corresponding to\\n\"\n"
+ "... \"1 102742238 CN A 2012-10-17 ZTE USA Inc. US20130094411A1\\n\"\n"
+ "... \"3 20150318972 2015-11-05 Zhang et al.\\n\"\n"
+ "... \"2 20130128860 2013-05-23 Zhang\\n\"\n"
+ "... \"1 20130094411 2013-04-18 Zhang\\n\"\n"
+ "... \"EFS Web 2.1.17\\n\"\n"
+ "... \"Examiner Signature Date Considered\\n\"\n"
+ "... \"3rd Generation Partnership Project; Technical Specification Group Radio Access Network; Evolved Universal\\n\"\n"
+ "... \"1 Terrestrial Radio Access (E-UTRA); Physical channels and modulation (Release 12), 3GPP TS 36.211 V12.7.0\\n\"\n"
+ "... \"fONAR_ NAN 12R nanac\\n\"\n"
+ "... \"vs Corresponding to\\n\"\n"
+ "... \"4 2014110837 WO Al 2014-07-24 Fujitsu Ltd. et al. US20150318972A1\\n\"\n"
+ "... \"3 2014107012 WO Al 2014-07-10 LG Electronics Inc.\\n\"\n"
+ "... \"; Corresponding to\\n\"\n"
+ "... \"2 103120006 CN A 2013-05-22 ZTE Corporation US20130128860A1\\n\"\n"
+ "... \"EFS Web 2.1.17\\n\"\n"
+ "... \"| |\\n\"\n";
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