I am using this piece of code if the pattern matches. It should through the error if the input includes Numbers,extra space,special characters. For that I have written the below code.
Pattern pattern = Pattern.compile("[^A-Za-z{',-}]"); Matcher match = pattern.matcher("1xyz");
In output I am getting message as "There is a no special character in my string for first name" In pattern match I have only given match iff we have letters, -,' as special characters. but its going take numbers also as acceptance not sure why. Can anyone help me on this
Aucun commentaire:
Enregistrer un commentaire