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
|
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegTest {
Pattern patt = Pattern.compile("[a-zA-Z]{5}[0-9]{5}");
Matcher match = patt.matcher("12345azertAZERT");
public RegTest(){
}
public void searchMatch(){
if(match.find()){
for(int i =0; match.find(); i++){
System.out.println("Ok ?"+match.find());
System.out.println("Trouvé: "+match.group());
}
}
else if(!match.find()){
System.out.println("Ok ?"+match.find());
System.out.println("Le mot de passe n'est pas assez robuste.");
}
}
public static void main(String[] args){
new RegTest().searchMatch();
}
} |