curriculum/challenges/english/blocks/learn-regular-expressions-by-building-a-password-generator/6564d75a923d21815caaa445.md
If you need to match a character that has a special meaning in the pattern, such as . or +, you can escape it by prepending a backslash character, \. For example, this matches a literal plus sign: \+.
Modify pattern so that it matches a single literal dot.
You should modify your pattern variable into \..
({ test: () => assert.match(code, /^pattern\s*=\s*("|')\\\.\1/m) })
import re
import secrets
import string
def generate_password(length, nums, special_chars, uppercase, lowercase):
# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
# Combine all characters
all_characters = letters + digits + symbols
while True:
password = ''
# Generate password
for _ in range(length):
password += secrets.choice(all_characters)
constraints = [
(nums, '[0-9]'),
(lowercase, '[a-z]'),
(uppercase, '[A-Z]'),
(special_chars, '')
]
return password
# new_password = generate_password(8)
# print(new_password)
--fcc-editable-region--
pattern = '.+'
quote = 'Not all those who wander are lost.'
print(re.findall(pattern, quote))
--fcc-editable-region--