Skip to content

Commit b240e4e

Browse files
authored
Add files via upload
1 parent da500b6 commit b240e4e

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

RGB.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from PIL import Image
2+
3+
file_name = "MonaLisa.jpg"
4+
img = Image.open(file_name)
5+
img.show()
6+
7+
colors = img.getpixel((320, 240))
8+
9+
print(colors)

Regex_Phone_and_email_extract.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import re
2+
import pyperclip
3+
4+
# Create phone regex.
5+
phone = re.compile(r'''(
6+
(\d{3}|\(\d{3}\))?
7+
(\s|-|\.)?
8+
(\d{3})
9+
(\s|-|\.)
10+
(\d{4})
11+
(\s*(exr|x|ext.)\s*(\d{2, 5}))?
12+
)''', re.VERBOSE)
13+
14+
# Create email regex.
15+
email = re.compile(r'''(
16+
[a-zA-Z0-9._%+-]+
17+
@
18+
[a-zA-Z0-9.-]+
19+
(\.[a-zA-Z]{2,4})
20+
)''', re.VERBOSE)
21+
22+
# Find matches in clipboard text.
23+
text = str(pyperclip.paste())
24+
25+
matches = []
26+
for groups in phone.findall(text):
27+
phoneNum = '-'.join([groups[1], groups[3], groups[5]])
28+
if groups[8] != '':
29+
phoneNum += ' x' + groups[8]
30+
matches.append(phoneNum)
31+
for groups in email.findall(text):
32+
matches.append(groups[0])
33+
34+
# Copy results to the clipboard.
35+
if len(matches) > 0:
36+
pyperclip.copy('\n'.join(matches))
37+
print('Copied to clipboard:')
38+
print('\n'.join(matches))
39+
else:
40+
print('No phone numbers or email addresses found.')

0 commit comments

Comments
 (0)