Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Bàn luận
- Trong chương trình này, chúng tôi sẽ lấy mật khẩu như là sự kết hợp của các ký tự chữ và số cùng với các ký tự đặc biệt và kiểm tra xem mật khẩu có hợp lệ hay không với sự trợ giúp của một vài điều kiện.
- Điều kiện chính để xác thực mật khẩu:
- Tối thiểu 8 ký tự.
- Bảng chữ cái phải nằm giữa [A-Z]
- Ít nhất một bảng chữ cái nên có trường hợp trên [A-Z]
Examples:
Input : R@m@_f0rtu9e$ Output : Valid Password Input : Rama_fortune$ Output : Invalid Password Explanation: Number is missing Input : Rama#fortu9e Output : Invalid Password Explanation: Must consist from _ or @ or $
Ít nhất 1 số hoặc chữ số giữa [0-9].
Ít nhất 1 ký tự từ [_ hoặc @ hoặc $].re module that provides support for regular expressions in Python. Along with this the re.search[] method returns False [if the first parameter is not found in the second parameter] This method is best suited for testing a regular expression more than extracting data. We have used the re.search[] to check the validation of alphabets, digits, or special characters. To check for white spaces we use the “\s” which comes in the module of the regular expression.
Python3
Cách 1: & nbsp;
Ở đây chúng tôi đã sử dụng mô -đun RE cung cấp hỗ trợ cho các biểu thức thường xuyên trong Python. Cùng với điều này, phương thức RE.Search [] trả về FALSE [nếu không tìm thấy tham số đầu tiên trong tham số thứ hai] Phương thức này phù hợp nhất để kiểm tra biểu thức thông thường nhiều hơn là trích xuất dữ liệu. Chúng tôi đã sử dụng Re.Search [] để kiểm tra xác thực bảng chữ cái, chữ số hoặc ký tự đặc biệt. Để kiểm tra các không gian trắng, chúng tôi sử dụng các \ s, trong mô -đun của biểu thức thông thường. & NBSP;
R@m@_f0rtu9e$& quot
import
re
password
=
"
flag
=
0
import
8import
9re
0
import
0 import
1import
2
re
1re
7
import
3import
4 import
5import
6import
7
password
2password
3re
4password
5
import
0 import
1import
2
re
1re
7
import
3import
4 import
5import
6import
7
password
2=
8re
4"
0
import
0 import
1import
2
re
1re
7
import
3import
4 import
5import
6import
7
password
2R@m@_f0rtu9e$& quot
30
re
4R@m@_f0rtu9e$& quot
6R@m@_f0rtu9e$& quot
7
import
0 import
1import
2
re
1re
7
import
3import
4 import
5import
6import
7
password
2=
0
import
0 import
1import
2
import
3import
4 import
5import
6import
7
re
1flag
=
re
4re
5
0
10
2
import
0 import
1import
2
re
1re
7
import
3import
01import
2
import
3import
4 import
5import
6import
7
re
1import
08import
09
import
10import
11
import
10import
13
re
1re
7
re
1flag
=
re
4re
5
import
3import
08import
09
import
26import
27
import
26import
13
import
3re
9 password
0 password
1
Python3
re
1re
7
import
3re
9 password
1
re
1flag
____4 0
import
4 flag
=
=
re
4re
5import
2
Cách 2: & nbsp;
import
8import
58import
59=
re
5
import
30=
0
import
330
import
330
import
330
import
39=
import
41
import
4 import
5import
6import
45=
import
9re
0
import
8import
74import
59=
re
5
import
3import
50 import
51import
52 import
53
import
8import
96import
59=
re
5
re
1import
4 import
56
import
3import
08re
30
import
01import
2
import
3import
08re
35
re
1import
4 import
64Without using any built-in method
Python3
re
1re
7
import
3re
9 password
1
re
48=
re
50
re
51=
re
53
re
54=
re
56
re
57=
re
59
re
1flag
____4 0
import
4 flag
=
=
re
4re
5import
2
Cách 2: & nbsp;
import
8import
58import
59=
re
5
import
30=
0
import
330
import
330
import
330
import
39=
import
41
re
1import
4 re
74import
52 re
96
import
8import
74import
59=
re
5
re
1import
4re
74import
52 password
06
import
8import
96import
59=
re
5
import
4 ______201
import
3import
08import
5password
43import
13
import
01import
2
import
3import
08import
5password
50import
13