-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_regex.py
More file actions
135 lines (101 loc) · 3.61 KB
/
Copy pathexample_regex.py
File metadata and controls
135 lines (101 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import pyperclip, re
li = ['aSWe4ew1', 'aaaaaaaa', '11111111', 'Qwertyui870']
for val in li:
if re.match(r'([a-z][A-Z]\w{1,})', val) and len(val)>= 7:
print ('yes')
else:
print ('no')
#Напишите функцию, которая использует регулярные выражения для
#проверки того, что переданная ей строка представляет собой сильный пароль.
#Сильными считаются пароли, которые состоят по крайней мере
#из 8 символов, содержат символы в ВЕРХНИХ и нижних регистрах и
#и включают по меньшей мер одну цифру.
def strongPassword():
testPassword = str(input())
testRegex = re.compile(r'([A-Za-z0-9@#$%^&+=]{8,})')
test = testRegex.search(password)
if (test):
print('Идеальный пароль')
else:
print('Плохой пароль')
#! python3
# phoneAndEmail.py - Finds phone numbers and email addresses on the clipboard.
import pyperclip, re
text = str(pyperclip.paste())
def checkPhone(text):
phoneRegex = re.compile(r'''(
(\d{3}|\(\d{3}\))?
(\s|-|\.)?
(\d{3})
(\s|-|\.)
(\d{4})
(\s*(ext|x|ext.)\s*(\d{2,5}))?
)''', re.VERBOSE)
matches = []
for groups in phoneRegex.findall(text):
phoneNum = '-'.join([groups[1],groups[3],groups[5]])
if groups[8] != '':
phoneNum += ' x' + groups[8]
matches.append(groups[0])
if len(matches) > 0:
pyperclip.copy('\n'.join(matches))
print('Скопировано в буфер офмена:')
print('\n'.join(matches))
else:
print('Ничего не обнаружено')
#text = str(pyperclip.paste())
def checkEmail(text):
matches = []
emailRegex = re.compile(r'''(
[a-zA-Z0-9._%+-]+
@
[a-zA-Z0-9.-]+
(\.[a-zA-Z]{2,4}){1,2}
)''', re.VERBOSE)
for groups in emailRegex.findall(text):
matches.append(groups[0])
if len(matches) > 0:
pyperclip.copy('\n'.join(matches))
print('Скопировано в буфер офмена:')
print('\n'.join(matches))
else:
print('Ничего не обнаружено')
#! python3
# phoneAndEmail.py - Finds phone numbers and email addresses on the clipboard.
def checkPhone(text):
phoneRegex = re.compile(r'''(
(\d{3}|\(\d{3}\))?
(\s|-|\.)?
(\d{3})
(\s|-|\.)
(\d{4})
(\s*(ext|x|ext.)\s*(\d{2,5}))?
)''', re.VERBOSE)
matches = []
for groups in phoneRegex.findall(text):
phoneNum = '-'.join([groups[1],groups[3],groups[5]])
if groups[8] != '':
phoneNum += ' x' + groups[8]
matches.append(groups[0])
if len(matches) > 0:
pyperclip.copy('\n'.join(matches))
print('Скопировано в буфер офмена:')
print('\n'.join(matches))
else:
print('Ничего не обнаружено')
def checkEmail(text):
matches = []
emailRegex = re.compile(r'''(
[a-zA-Z0-9._%+-]+
@
[a-zA-Z0-9.-]+
(\.[a-zA-Z]{2,4}){1,2}
)''', re.VERBOSE)
for groups in emailRegex.findall(text):
matches.append(groups[0])
if len(matches) > 0:
pyperclip.copy('\n'.join(matches))
print('Скопировано в буфер офмена:')
print('\n'.join(matches))
else:
print('Ничего не обнаружено')