import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?>[^;]*;){5}(?>[^,]*,){2}\\s*[^,^\\s]*\\s*([^,^;]*)(?>[^;^\\r^\\n]*)";
final String string = "2009311179;2723088770;Комсомольское отделение филиала ПАО \"ДЭК\"-\"Хабаровскэнергосбыт\";2018-10-23;0de159ee-ebc3-4a1e-81ca-63d8fe5a8558;1093163;Хабаровский край, Солнечный район, п. Хурмули, ул. Школьная, д. 20;;Солнечный;;;421;;Школьная;529;20;;;7;1;16;2012-08-01;65,1;41,3;2012-08-01;3;1;12DEC0701E80601161;;2012-08-01;;Капарушкин;Виталий;Викторович;;;4;4;;2012-08-01";
final Pattern pattern = Pattern.compile(regex, Pattern.COMMENTS);
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