Skip to content

Commit d63b83b

Browse files
committed
RegEx Example
1 parent 03223f8 commit d63b83b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

RegEx_password_validation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Using RegEx, construct a password validation that contains
2+
# At least 8 characters
3+
# contains any type of letters, numbers and $%#@
4+
# and ends with a number
5+
6+
import re
7+
8+
pattern = re.compile(r'[a-zA-Z0-9$%#@]{8,}\d$')
9+
string = 'user123$#@3'
10+
a = pattern.fullmatch(string)
11+
12+
if a == None:
13+
print('your password must be at least 8 digits long\n contain letters, numbers, any of these symbols $%#@ and end with a number')
14+
15+
else:
16+
print('logged in')

0 commit comments

Comments
 (0)