mercredi 24 juin 2015

Java pattern first letter should not be hyphens (-), apostrophes (‘), and spaces ( ) [duplicate]

This question already has an answer here:

I am using this pattern to check

public static final Pattern VALID_FIRST_CHARACTERS = Pattern.compile("^[\\ \\'\\-]");

public boolean isValidFirstChar(String name) {
    if (VALID_FIRST_CHARACTERS.matcher(name).matches()) {
        return true;
    }
    return false;
}

no luck, can somebody help me please ?

Aucun commentaire:

Enregistrer un commentaire