@@ -1197,16 +1197,16 @@ public String regexYamlString(String champ, String texte) {
11971197 String groupe2 = m .group (2 );
11981198 String groupe3 = m .group (3 );
11991199 Integer spaces = 2 ;
1200- if (groupe2 .length () > 0 )
1200+ if (groupe2 != null && groupe2 .length () > 0 )
12011201 spaces = Integer .parseInt (groupe2 );
12021202 o = groupe3 .replaceAll ("^" + String .join ("" , Collections .nCopies (spaces , " " )), "" ).replaceAll ("\n " + String .join ("" , Collections .nCopies (spaces , " " )), "\n " );
12031203
1204- if (groupe1 .contains (">" ))
1204+ if (groupe1 != null && groupe1 .contains (">" ))
12051205 o = o .replaceAll ("\\ n([^\\ n])" , " $1" );
12061206
1207- if (groupe1 .contains ("-" ))
1207+ if (groupe1 != null && groupe1 .contains ("-" ))
12081208 o = o .replaceAll ("\\ n+\\ Z" , "" );
1209- else if (!groupe1 .contains ("+" ))
1209+ else if (groupe1 == null || !groupe1 .contains ("+" ))
12101210 o = o .replaceAll ("\\ n\\ Z" , "" );
12111211 } else {
12121212 motif = "^" + champ + ": (.*)" ;
@@ -1221,6 +1221,42 @@ else if(!groupe1.contains("+"))
12211221 return o ;
12221222 }
12231223
1224+ public String regexLangueYamlString (String langueNom , String champ , String texte ) {
1225+ String o = null ;
1226+ if (champ != null && texte != null ) {
1227+ String motif = "^" + champ + "(\\ ." + langueNom + ")?: ?([>|-]{0,2}(\\ d*)\\ n)?([\\ s\\ S]*?)(?=\\ n^\\ w|\\ Z)" ;
1228+ Matcher m = Pattern .compile (motif , Pattern .MULTILINE ).matcher (texte );
1229+ boolean trouve = m .find ();
1230+ if (trouve ) {
1231+ String groupe1 = m .group (1 );
1232+ String groupe2 = m .group (2 );
1233+ String groupe3 = m .group (3 );
1234+ String groupe4 = m .group (4 );
1235+ Integer spaces = 2 ;
1236+ if (groupe3 != null && groupe3 .length () > 0 )
1237+ spaces = Integer .parseInt (groupe3 );
1238+ o = groupe4 .replaceAll ("^" + String .join ("" , Collections .nCopies (spaces , " " )), "" ).replaceAll ("\n " + String .join ("" , Collections .nCopies (spaces , " " )), "\n " );
1239+
1240+ if (groupe2 != null && groupe2 .contains (">" ))
1241+ o = o .replaceAll ("\\ n([^\\ n])" , " $1" );
1242+
1243+ if (groupe2 != null && groupe2 .contains ("-" ))
1244+ o = o .replaceAll ("\\ n+\\ Z" , "" );
1245+ else if (groupe2 == null || !groupe2 .contains ("+" ))
1246+ o = o .replaceAll ("\\ n\\ Z" , "" );
1247+ } else {
1248+ motif = "^" + champ + ": (.*)" ;
1249+ m = Pattern .compile (motif , Pattern .MULTILINE ).matcher (texte );
1250+ trouve = m .find ();
1251+ if (trouve ) {
1252+ String groupe2 = m .group (1 );
1253+ o = groupe2 ;
1254+ }
1255+ }
1256+ }
1257+ return o ;
1258+ }
1259+
12241260 /**
12251261 * Param1.var.enUS: pattern Param2.var.enUS: text Param3.var.enUS: group r:
12261262 * motif r.enUS: pattern r: texte r.enUS: text r: groupe r.enUS: group r: trouve
@@ -1275,7 +1311,7 @@ protected ArrayList<String> regexLangueListe(String langueNom, String nomChampRe
12751311 ArrayList <String > resultats = new ArrayList <String >();
12761312 String o = null ;
12771313 if (nomChampRegex != null && commentaire != null ) {
1278- Matcher m = Pattern .compile ("^" + nomChampRegex + "(." + langueNom + ")?:\\ s*(.*)" , Pattern .MULTILINE )
1314+ Matcher m = Pattern .compile ("^" + nomChampRegex + "(\\ ." + langueNom + ")?:\\ s*(.*)" , Pattern .MULTILINE )
12791315 .matcher (commentaire );
12801316 boolean trouve = m .find ();
12811317 while (trouve ) {
0 commit comments