import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?i)^\\D{2,}\\.(\\D)\\.\\D{2}.*$";
final String string = "GO.C.O.3 - App - IQOS Connect Widget (production)\n"
+ "GO.C.X.1 - App - IQOS Connect (raw)\n"
+ "GO.C.X.2 - App - My IQOS App (raw)\n"
+ "GO.C.X.3 - App - IQOS Connect Widget (raw)\n"
+ "GO.W.O.1 - iqos.com (production)\n"
+ "GO.W.U.1 - iqos.com (user-id)\n"
+ "GO.W.X.1 - iqos.com (raw)\n"
+ "OBSOLETE - GO.W.X.2 - iqos.com (raw excl. params)\n"
+ "OBSOLETE - Test view\n"
+ "AL.A.O.1 - Consolidated (production)\n"
+ "AL.A.X.1 - Consolidated (raw)\n"
+ "AL.W.O.1 - al.iqos.com (production)\n"
+ "AL.W.U.1 - al.iqos.com (user-id)\n"
+ "AL.W.X.1 - al.iqos.com (raw)\n"
+ "ar.myiqos.com (raw)\n"
+ "AR.W.O.1 - iqos.com.ar (production)\n"
+ "AM.A.O.1 - Consolidated (production)\n"
+ "AM.A.X.1 - Consolidated (raw)\n"
+ "AM.W.O.1 - am.iqos.com (production)\n"
+ "AM.W.U.1 - am.iqos.com (user-id)\n"
+ "AM.W.X.1 - am.iqos.com​ (raw)\n"
+ "All Web Site Data\n"
+ "AT.A.O.1 - Consolidated (production)\n"
+ "AT.A.X.1 - Consolidated (raw)\n"
+ "AT.W.O.1 - at.iqos.com (production)\n"
+ "AT.W.U.1 - at.iqos.com (user-id)\n"
+ "AT.W.X.1 - at.iqos.com (raw)\n"
+ "AT.Z.O.1 - iqosinfo.at\n"
+ "AT.Z.O.2 - iqosjetzt.com\n"
+ "AT.Z.O.3 - iqosempfehlen.at\n"
+ "AT.Z.O.4 - iqostesten.at\n"
+ "AT.Z.O.5 - testeiqos.at\n"
+ "AT.Z.O.6 - iqosregistrieren.at\n"
+ "AT.Z.O.7 - iqosprobieren.at";
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