I want to be sure that a String contains only alpha characters (with special character like "é", "è", "ç", "Ç", "ï"
, etc etc.).
I did that, but with special characters returns false...
if (myString.matches("^[a-zA-Z]+$")) {
return true;
}
Thanks guys!
You can use Unicode Category: \\p{L}
or \\P{Letter}
to match any kind of letter from any language.
if (myString.matches("\\p{L}+")) {
return true;
}
BTW, String.matches
try to match entire string, so ^
, $
anchors are not necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With