I want to return true if name is valid. Name can contain:
- upper or lower case characters
- no numbers or special characters
- can be one or two words with a single space in the middle
- first name and last name can be between 2-25 characters each
eg.
John Smith
= trueJohn
= trueJoHn
= trueJohn Sm1th
= falseJohn $mith
= falseJ0hn
= falseJohn Smith
= false (two spaces between names)
Here is my code thus far. It fails some of these test cases.
import re
if re.findall('[A-Za-z]{2,25}\s[A-Za-z]{2,25}', string):
print("true")
else:
print("false")
re.findall
butre.match
. – Casimir et Hippolyte