import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "org.alluxio<name=\"*([a-zA-Z_\\.]+)\\.([0-9\\.]+)\"*,*[^:,\\n]*><>(\\w+)Rate";
final String string = "org.alluxio<name=Master.GetFingerprint.UFS:s3a:%2F%2Frzp-si-dashboard%2F.UFS_TYPE:s3, type=timers><>50thPercentile\n"
+ "org.alluxio<name=Master.registerMaster.User:alluxio\n"
+ "org.alluxio<name=Master.EmbeddedJournalSnapshotReplayTimer, type=timers><>50thPercentile\n"
+ "org.alluxio<name=Master.InodeCacheEvictions, type=counters><>Count\n"
+ "org.alluxio<name=\"Master.getConfigHash.User:trino:afd\", type=counters><>Count\n"
+ "org.alluxio<name=Master.GetSpace.User:alluxio.UFS:s3:%2F%2Frzp-edh-prod%2Falluxio%2Falluxio-dev.UFS_TYPE:s3.fd, type=timers><>50thPercentile\n"
+ "org.alluxio<name=Master.GetSpace.User:alluxio.UFS:s3:%2F%2Frzp-edh-prod%2Falluxio%2Falluxio-dev.UFS_TYPE:s3.fd><>50thPercentile\n"
+ "org.alluxio<name=Master.JournalGainPrimacyTimer, type=timers><>50thPercentile\n"
+ "org.alluxio<name=\"Master.UfsSessionCount-Ufs:s3:%2F%2Frzp-prod-datum%2Fpa_sheets%2FXFinopsIncidentTracker%2FIncidentTracker\"><>Count\n"
+ "org.alluxio<name=Worker.BytesReadRemoteThroughput.10.44.21.20, type=meters><>OneMinuteRate";
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