Il y a une corde
String str = "ggg;ggg;nnn;nnn;aaa;aaa;xxx;xxx;";
Comment puis-je le diviser en chaînes comme celle-ci "ggg; ggg;" "nnn; nnn;" "aaa; aaa;" "xxx; xxx;" ???????
Utilisation de Regex
String input = "ggg;ggg;nnn;nnn;aaa;aaa;xxx;xxx;";
Pattern p = Pattern.compile("([a-z]{3});\\1;");
Matcher m = p.matcher(input);
while (m.find())
// m.group(0) is the result
System.out.println(m.group(0));
Sortira
ggg; ggg;
nnn; nnn;
aaa, aaa;
xxx; xxx;
Cet article est collecté sur Internet, veuillez indiquer la source lors de la réimpression.
En cas d'infraction, veuillez [email protected] Supprimer.
laisse moi dire quelques mots