import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^[0-9A-F]{32}$";
final String string = "fab4cc07260bc73302a2653aa2b0e6de\n"
+ "46cc38cc1039848dc287162cc4cf2532\n"
+ "a065c2cf24295a13725af9c5dc8cc76c\n"
+ "87d0f33c047915a0000ca972f3b32adc\n"
+ "43da9d5db71bedf3afc6f10fc8297a00\n"
+ "3fcca411d6774571a81a9faa4026c69a\n"
+ "9f36002354b2b75a069facac88ce5651\n"
+ "064ec24407084bf597c7dc1edc3f9017\n"
+ "3f5cfb400d72c7b3663b617368a0b3af";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | 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