AutomateTheBoringStuff.Ch07.Projects package¶
Submodules¶
AutomateTheBoringStuff.Ch07.Projects.P1_strongPwDetect module¶
Strong password detection
This program ensures passwords entered are “strong.”
Write a function, is_strong_pw()
, that uses regular expressions to make sure
the password string it is passed is strong.
A strong password is defined as one that is at least eight characters long, contains both uppercase and lowercase characters, and has at least one digit.
Note
You may need to test the string against multiple regex patterns to validate its strength.
-
AutomateTheBoringStuff.Ch07.Projects.P1_strongPwDetect.
is_strong_pw
(text: str) → bool[source]¶ Is strong password
Uses three
re
object patterns to check if a given text is at least 8 numbers and characters long, has at least one uppercase and lowercase character, and has at least one digit.Parameters: text – String containing password to test strength of. Returns: True if the given text matches the regex patterns, False otherwise.
AutomateTheBoringStuff.Ch07.Projects.P2_regexStrip module¶
Regex version of strip()
This program acts like str.strip()
but using re
.
Write a function, regex_strip()
, that takes a string and does the same thing
as the strip() string method.
If no other arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the characters specified in the second argument to the function will be removed from the string.
-
AutomateTheBoringStuff.Ch07.Projects.P2_regexStrip.
regex_strip
(text: str, replace: str = '') → str[source]¶ Regex strip
Implements the
str.strip()
method usingre
by removing the given replace string in the given text.Parameters: - text – String with text to remove given replace string from.
- replace – String to remove from given text. Defaults to empty string.
Returns: String with replace string removed from text string.