1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| String text = txtAreaCadre2.getText();
Pattern p1 = Pattern.compile("\\b+[A-Z]\\w+");
Matcher x = p1.matcher(text);
//on utilise une expression régulière
//"\\b+[A-Z]\\w+" = le \\b veut dire un séparateur de mots (espace, ",", ";" ...)
//le [A-Z]\\w+ = les mots qui commencent par une majuscule et qui contiennent des
//caractères alphanumérique et _
Pattern p = Pattern.compile("\\b+[A-Z]\\w+");
Matcher m = p.matcher(text);
//tant qu'on trouve une correspondance, on l'ajoute à la combo
while (m.find()) {
if (m != x) {
jComboBox1.addItem(m.group());
redondance.add(jComboBox1);
System.out.println(redondance);
for (int i = 0; i < redondance.size(); i++) {
if (redondance.get(i)!=redondance.get(i+1)) {
jComboBox1.addItem(redondance);
}
}
}
} |
Partager