import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\(loggingInfo\\)|\\(beneLoggingInfo\\)) - (?<vendorinfo>[^|]*)\\|(?<login>[^|]*)\\|(?<action>[^|]*)\\|(?<timeStamp>[^\\|]*)\\|(?<tag2>[^\\|]*)\\|(?<tag6>[^\\|]*)\\|(?<tag7>[^\\|]*)\\|(?<tag8>[^\\|]*)\\|(?<tag9>[^\\|]*)\\|(?<tag10>[^\\|]*)\\|(?<tag11>[^\\|]*)\\|";
final String string = "18 Jul 2018 09:05:31,068 INFO (loggingInfo) - Auto CRM|ppope|ApplicationLogin|Wed Jul 18 09:05:31 CDT 2018|CSR agent successfully logged in||Successful||||NA|\n\n"
+ "22 Oct 2018 08:36:41,164 INFO (beneLoggingInfo) - Beneficiary Administration|TESTWHBENE|APPLICATION LOGIN|Mon Oct 22 08:36:41 CDT 2018|User successfully logged in for Client = 070||SUCCESSFUL||||NA|\n\n"
+ "22 Oct 2018 00:43:23,845 INFO (loggingInfo) - Inquiry Application|TUSER4444|APPLICATION LOGIN|Mon Oct 22 00:43:23 CDT 2018|User successfully logged in for Client : 580||SUCCESSFUL||||NA|\n\n"
+ "01 Oct 2018 09:29:33,508 INFO (loggingInfo) - ISIS PersonalPlan|TESTOMAR|APPLICATION LOGIN|Mon Oct 01 09:29:33 CDT 2018|User successfully logged in for Client : 002||SUCCESSFUL||||NA|\n\n"
+ "24 Oct 2018 13:46:07,647 INFO (loggingInfo) - Web-Billing|egunderson| User Authentication|10/24/2018 01:46:07 PM| User Authentication|NA|True| NA| NA| NA| NA|\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