Bonjour,
j'ai essayé plusieurs tutoriaux sur le net traitant des expressions régulières mais je me confronte toujours à un problème que je ne comprends pas. Eclipse ne veut pas de ma variable String pour la méthode Pattern.compile(), pourtant la doc java indique le contraire.
Voila mon code, basé sur ce que j'ai trouvé sur ce tuto très complet:
http://cyberzoide.ftp-developpez.com/java/regex.pdf
En souligné -> Ce que Eclipse me souligne en rouge
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public boolean testChaineCaractere(String regex, String chaine){ boolean bool = true; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(chaine); while(matcher.find()){ System.out.println("Trouvé !"); bool=false; } return bool; }
Voici le début de l'erreur quand je tente de me servir de la fonction:
J'ai essayé un tas de truc mais ça ne change rien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Exception occurred during event dispatching: java.lang.Error: Unresolved compilation problems: The method compile(ClassGenerator, MethodGenerator) in the type Expression is not applicable for the arguments (String) The method matcher(String) is undefined for the type Pattern The method find() is undefined for the type Selector.Matcher
Merci d'avance pour votre aide
Partager