2
I have a function in c++
validates name and surname with the following regex
:
"((?:[á-úA-Za-z]+[ ]+[á-úA-Za-z]{0,20})?)?"
was taking a look to let learn to create regex
otherwise based on what is here on this website:
https://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html
then I did it:
"((?:[[:alpha:]]+[[:space:]]+[[:alpha:]]{0,20})?)?"
but names like Caesar and Tião it does not validate how I do it based on that kind of regex
?
Possible duplicate of To validate with regex a string containing only letters, whitespace and accented letters?
– Oralista de Sistemas
that there is for java I am doing for c++ I tried to use this link you marked as duplicate to understand how to sweat Posix regex but I did not find anything that makes me accept accented names, alias if I do not use alpha or apace using letters it validates quietly...
– dark777
Try this Regex:
[A-ZÀ-Ý][a-zA-ZÀ-ÿ]+\s*[A-ZÀ-Ý][a-zA-ZÀ-ÿ]+
and the demo. I never used Posix, but the regexplanet apparently validated this expression in Posix.– danieltakeshi
My God I am not speaking of this regex: "(?:[á-úa-Za-z]+[ ]+[á-úa-Za-z]{0,20})?)?" validates names and surnames with or without accents if to exchange one syntax for the other is not worth I’m talking about using something like [:alpha:] [:alnum:] and do based on what is recognized eats with accents..
– dark777
Read this reference and you will see that alpha does not include accentuation. Therefore, you have to use:
[[:alpha:]À-ÿ]+
. I suggest be more specific in your questions, thus, there is more chance of it being answered correctly. Including using the correct Tags and giving examples in a mcve.– danieltakeshi
more aesthetical than that? I have a c++ function that validates first and last names with the following regex : "((?:[á-úa-Za-z]+[ ]+[á-úa-Za-z]{0,20})?)?" was taking a look to let you learn how to create regex otherwise based on what’s on this site: https://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html so I did this: "((?:[[:alpha:]]+[[:space:]]+[[:alpha:]]{0,20})?)?" but names like Caesar and Tião it does not validate how I do it based on this type of regex?
– dark777