import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "Judge(?: +[A-Z][^\\W\\d_]*\\.?)*";
final String string = "® @ Stperio,l LED\n"
+ ">\n"
+ "Cay\n"
+ "OCT 9, \"se\"\n"
+ "-aeentative Ruling Sherr p 8 29\n"
+ "by C. 17\n"
+ "% Exeo, ive On Z—\n"
+ "Judge Randolph M. Hammock, Department 47 Fie oH/erp\n"
+ "a, Copy,\n"
+ "HEARING DATE: October 18, 2017 TRIAL DATE: March 27, 20 18\n"
+ ". CASE: Roger Lee Harrison v. Taylor Hackford, et al. ©\n"
+ "CASE NO.: BC596850";
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