import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "Remarks: ([^\\r]+)Members:";
final String string = "GBRG0A 00005 JULIEx 11/27/17 11:03:12 X3311073-00X DAMAGE\n\n"
+ "Dig No : X3311073 Rev : 00X Digstart: 11/27/17 11:01\n"
+ "Rcvd : 11/27/17 11:03 Priority: 0 Expires : 12/24/17 23:59\n"
+ "Org Dig: X3311073 Rcvd: 11/27/17 11:01\n\n"
+ "Firm : KNOX CONSTRUCTION Caller: DUSTIN KNOX\n"
+ "CoAddr1: 1386 BRIDGEPORT RD\n"
+ "City,St: MAQUON, IL Zip : 61458\n"
+ "Phone : 309-337-6576 Ext :\n"
+ "Call Bk: Done For : PATTY BAILEY\n"
+ "SiteCnt: DUSTIN KNOX Phone : 309-337-6576\n\n"
+ "County : KNOX Place: GALESBURG CIT\n"
+ "Address: 522 ISLE ROYALE RD\n"
+ "Subdiv : Cross: LOSEY ST\n\n"
+ "Grids : T11NR01E09SW\n\n"
+ "BestFit: 40.954957/-90.400618 40.954938/-90.399043\n"
+ " : 40.953819/-90.400632 40.953799/-90.399057\n"
+ "PreMark: YES Directional Boring: NO Depth>7Ft: NO\n"
+ "Locatn : IN THE CITY OF GALESBURG,\n"
+ "WrkType: FENCE POST INSTALLATION ***HIT LINE****\n"
+ "Extent : LOCATE: THE WEST SIDE OF THE HOUSE.\n"
+ "Remarks: REFER TO DIG# X003241591 TO ALL COMPANIES, CALLER STATES HIT A\n"
+ " : MISMARKED CENTURY LINK LINE. CREW IS ON SITE. CALLED IN BY DUSTIN.\n\n"
+ "Members: COMC0A GBRG0A GSD0A GSD0B IPC6A SCNT3A USIC0A\n\n"
+ "View map at:\n"
+ "http://newtin.julie1call.com/newtinweb/map_tkt.nap?TRG=32WSVUQRTTVORRtwo2";
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