import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(?:.*?\\x7C){14}(?'champs1'.*?)\\x7C(?:.*?\\x7C){6}(?'champs2'.*?)\\x7C(?'champs3'.*?)\\x7C";
final String string = "1906823505|BPA|CORENC-BPAUR0133|LR35788G|LEONETTI CATHERINE|04.76.88.14.14||INT|MG_ENS_010002|Ensemble Chauffage-Climatisation||MNT|MG116|05/06/2019 17:36:00|06/06/2019 10:36:00|4|FR|05/06/2019 16:36:00|BPA|CORENC-BPAUR0133|LR35788G|BPAURA-ENGIE LOIR|ENGIE COFELY LOIRE|0|||313|002|A1 - ESPACE 4|0|BP AUVERGNE RHONE ALPES (CORENC-BPAUR0133)|2 AVENUE DU GRESIVAUDAN||38700|CORENC|0438884619||||1906823505|merci d'intervenir pour rétablir la clim à l'agence";
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