I've this regex:
if (cadena.matches("^[a-zA-Z ]+$")) return true;
It's accepting from A to Z as lowercase and uppercase. Also accepting spaces.
But this is working just for english. For instance, in Catalan we've the 'ç' character. Also we've characters with 'á', or 'à', etc.
Did some google and I couldn't find any way to do this.
I found out that I can filter for UTF-8 but this would accept characters that are not really a letter.
How can I implement this?
$ means "Match the end of the string" (the position after the last character in the string).
To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).
A repeat is an expression that is repeated an arbitrary number of times. An expression followed by '*' can be repeated any number of times, including zero. An expression followed by '+' can be repeated any number of times, but at least once.
\n. Matches a newline character. \r. Matches a carriage return character.
Use this regex:
[\p{L}\s]+
\p{L}
means any Unicode letter.
fiddle.re Demo.
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