Extraire chaine de caractère
Fermé
khalous91
Messages postés
18
Date d'inscription
mercredi 15 avril 2015
Statut
Membre
Dernière intervention
17 juin 2015
-
Modifié par Whismeril le 15/04/2015 à 22:30
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 15 avril 2015 à 21:21
KX Messages postés 16668 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 17 mars 2023 - 15 avril 2015 à 21:21
A voir également:
- Extraire chaine de caractère
- Excel extraire chaine de caractère après un caractère ✓ - Forum Excel
- Caractère spéciaux - Guide
- Extraire video youtube - Guide
- Caractère invisible ✓ - Forum Windows
- Excel extraire chaine de caractère avant un caractère ✓ - Forum Excel
1 réponse
KX
Messages postés
16668
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
17 mars 2023
3 005
15 avril 2015 à 21:21
15 avril 2015 à 21:21
Bonjour,
Il me semble qu'un simple test
Remarque : en Java on peut manipuler des expressions régulières, ce qui rend ton problème très simple.
Il me semble qu'un simple test
if (tab[i].startsWith("#")) suffit
Remarque : en Java on peut manipuler des expressions régulières, ce qui rend ton problème très simple.
final Pattern PATTERN = Pattern.compile("\\{([^\\}]*)\\}");
Set<String> set = new LinkedHashSet<String>();
for (String line : string.split("\n")) {
if (line.startsWith("#"))
continue;
Matcher matcher = PATTERN.matcher(line);
while (matcher.find())
set.add(matcher.group(1));
}
System.out.println(set);