Jun-09-2024, 02:40 PM
Something like this?
If you want to ignore case add: re.IGNORECASE to the regexes
I don't think names will contain characters that need re.escape, but maybe you need to think about that if you have names like O'Keefe or O'Reilly.
And, you also need to re the name to make sure it suits!
un = input('Enter your username like this Schweinehund: Firstname.Lastname ') a = un.split('.') b = re.compile(a[0]) c = re.compile(a[1]) np = input('Enter your password Schweinehund! ') while not b.search(np) == None: np = input('Enter your password again Schweinehund, but don\'t use your first name in the password! ') while not c.search(np) == None: np = input('Enter your password again Schweinehund, but don\'t use your last name in the password! ')
Output:un
'Pedro.Rodriguez'
Output:np
pedro.RODRIGUEZ
While loopsOutput:Enter your password again Schweinehund, but don't use your first name in the password! prodriguez
Enter your password again Schweinehund, but don't use your last name in the password! pedror
Enter your password again Schweinehund, but don't use your first name in the password! PeterR
Jawohl!If you want to ignore case add: re.IGNORECASE to the regexes
I don't think names will contain characters that need re.escape, but maybe you need to think about that if you have names like O'Keefe or O'Reilly.
And, you also need to re the name to make sure it suits!