import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "((([0-9a-fxA-FX]){2})(?|[,\\n])){8,16}";
final String string = "Windows Registry Editor Version 5.00\n"
+ "[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\MultiKey\\Dumps\\D9DA0000]\n"
+ "\"DongleType\"=dword:00000003\n"
+ "\"Copyright\"=\"None\"\n"
+ "\"Created\"=\"Tue Jan 08 10:33:00.496 2013\" by dmp2mkey\n"
+ "\"Name\"=\"D9DA Sentinel SuperPro Dump\"\n"
+ "\"Type\"=dword:00000000\n"
+ "\"CellType\"=hex:\\ \n"
+ " 01,01,03,03,03,01,03,01,\\ \n"
+ " 03,03,00,00,00,00,00,00,\\ \n"
+ " 00,00,00,00,01,00,00,01,\\ \n"
+ " 00,00,01,00,00,01,00,00,\\ \n"
+ " 00,00,00,00,00,00,00,00,\\ \n"
+ " 00,01,00,00,00,00,00,00,\\ \n"
+ " 00,00,01,00,00,00,00,00,\\ \n"
+ " 00,00,00,00,00,00,00,00\n"
+ "\"sntMemory\"=hex:\\ \n"
+ " 01,1A,DA,D9,00,00,00,00,EF,5D,01,00,DE,59,11,00,\\ \n"
+ " 31,FA,A0,F0,00,00,00,00,F0,55,00,00,F0,55,00,00,\\ \n"
+ " F0,55,00,00,F0,55,47,00,01,00,FF,00,01,00,FF,00,\\\n"
+ " 01,00,FF,00,01,00,FF,00,01,00,FF,00,01,00,FF,00,\\\n"
+ " 01,00,FF,00,01,00,FF,00,01,00,FF,00,01,00,FF,00,\\\n"
+ " 01,00,FF,00,01,00,FF,00,01,00,FF,00,01,00,FF,00,\\\n"
+ " 01,00,FF,00,01,00,FF,00,01,00,FF,00,01,00,FF,00,\\\n"
+ " 01,00,FF,00,01,00,FF,00,01,00,FF,00,01,00,FF,00\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