I believe that you do not need numbers in the names, and you are looking for this regular expression:
^\p{L}+ \p{L}+$
or
^\p{L}+\s\p{L}+$
where \p{L}+ matches one or more characters of the letter, so not only az and az , but also characters from other languages. For example, Elise Wilson.
If you really need only alphanumeric characters, and the input should have two sections with one space between them; and invalid characters must be removed, and then:
- replace all matches
[^\s\dA-Za-z]+ with an empty string, - trim leading spaces by replacing
^\s* an empty string, - trim trailing spaces by replacing
\s*$ an empty string and - check / check such a string with the regular expression
^[\da-zA-Z]+ [\da-zA-Z]+$
To exclude numbers from a string, remove \d from previous patterns.
To allow a longer space between, and not just one run character, add + for the space in the first pattern or for \s in the second.
Ξ©mega
source share