Chercher Un mot dans un text
Bonjour Communauté :)
je suis face a un probleme de recherche d'un mot dans un text ..
j'ai utiliser pour la premiere solution cette version
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public void FindWords(String From) {
try{
String ligneLue;
LineNumberReader lnr=new LineNumberReader(new FileReader(RESULT));
try{
while((ligneLue=lnr.readLine())!=null){
SearchForWords(ligneLue,wordList);
}
}
finally{
lnr.close();
}
}
catch(IOException e){
System.out.println(e);}
}
public void SearchForWords(String Ligne,List<String> List){
for(String CAS :List){
if(Ligne.contains(CAS)){
System.out.print("J'ai Trouver le "+CAS);
break;
}} |
cette solution marche bien ...
Mais j'ai constate que les format des mots change d'un fichier a un autre .
Citation:
Par exemples j'ai une liste de mots qui contient "127-22-3","1778-22-4","888-56-3" ..
Mais dans les fichiers je peut trouver la structure comme ca
"127_22_3" un autre peut sous cette forme "127*22*3"
Citation:
comment je dois faire ,la methode contains ne sera plus valide
Merci pour votre aide ,Merci d'avance :ccool: