Bonjour, j'ai un souci dans l'utilisation d'une expression régulière où le résultat n'est pas ce que j'attends :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
	private ArrayList<File> chercherFichiersXmlAmap(String repertoireString)
	{
		ArrayList<File> fichiersXML = new ArrayList<File>();
 
		File repertoire = new File(repertoireString);
        if ( repertoire.isDirectory( ) ) 
        {
            File[] list = repertoire.listFiles();
            if (list != null){
                for ( int i = 0; i < list.length; i++) 
                {
                	System.out.println(list[i].toString());
                	if(checkXmlAmapFormat(list[i]))
                	{
                		fichiersXML.add(list[i]);
                		System.out.println("oui");
                	}
                	else
                		System.out.println("non");
                } 
            } else {
            	System.err.println(repertoire + " : Erreur de lecture.");
            	return null;
            }
        } 
 
		return fichiersXML;
	}
 
	private boolean checkXmlAmapFormat(File file) 
	{
		String fichier = file.getName();
 
		if(fichier.endsWith(".xml") && fichier.matches("^amap+_+[1-31]+_+[1-12]+_+[2000-2100]+.+xml"))
		return true;
 
		return false;
	}
J'obtiens ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.\saves\Test.xml
non
.\saves\Exercice1.xml
non
.\saves\Exercice2.xml
non
.\saves\mails_google.csv
non
.\saves\Result.xml
non
.\saves\amap_29_11_2011.xml
non
.\saves\amap_3_9_2029.xml
non
.\saves\amap_1_11_2010.xml
oui
En fait je ne comprends pas pourquoi amap_29_11_2011.xml et amap_3_9_2029.xml ne fonctionnent pas....

Ca doit venir de mon utilisation de l'expression régulière, mais je ne vois pas...

Merci,
Mathieu.