mardi 27 juin 2017

checking regular expressions, Java patterns [duplicate]

This question already has an answer here:

I am trying to check different expression through java.util.regex.Pattern but It doesn't work well.

The next code return "no" but in my opinion must be return "yes". What is the problem?

if (Pattern.compile("historic").matcher("ahistoricbuilding").matches()) {
    System.out.println("yes");
} else {
    System.out.println("no");
}

Thanks.

Aucun commentaire:

Enregistrer un commentaire