I want to include the space and only accept letters, numbers and accents and the special character ñ . What I have done is the following:
if (primernombre.length() == 0 || a.matches(".*[^a-zñáéíóúA-ZÑÁÉÍÓÚ].*")) {
primernombre.setError("Ingrese un nombre valido. Solo letras.");
what I am missing is to include the space and the numbers.
For example: this is a text so far it does not accept it, and my regular expression only accepts this is a text
Have you tried adding the space in your character set?
Your expression would look something like this
edited
You can also try this expression:
This expression will allow a string of at least one word and the words will be split by spaces.
^
Mark the beginning of the string\w+
Indicates a string of at least one word of a character or number( \w+)*
indicates a group that is repeated 0 or more times. A space followed by a string of at least one character or number is expected in the group.$
indicates the end of the stringThis can also be translated by the following expression: