Last active
June 22, 2019 03:27
-
-
Save tsuyukimakoto/0a2015114607fdde212335bb578e0ae2 to your computer and use it in GitHub Desktop.
assignable expression and regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def check(passwd): | |
if (password_length := len(passwd)) < 1: | |
return 'Need password' | |
if (m := re.search(r'^%s+' % passwd[0], passwd)) and m.span()[1] == password_length: | |
return '{0} contains only same character'.format(passwd) | |
return '{0} is suitable for password'.format(passwd) | |
if __name__ == '__main__': | |
print(check('')) | |
print(check('aaaa')) | |
print(check('aaac')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment