SHOW:
|
|
- or go back to the newest paste.
1 | #! python3 | |
2 | # website finder | |
3 | ||
4 | import re, pyperclip | |
5 | ||
6 | #website regex | |
7 | ||
8 | website_regex = re.compile(r'''( | |
9 | (http://|https://)? # http or https | |
10 | (www\.)? # starting optionally with 'www' | |
11 | [a-zA-Z0-9-]+ # any letter, digit and hyphens allowed | |
12 | (\.) # obligatory dot | |
13 | (\w)+ | |
14 | (\.)? # optional dot | |
15 | (\w)+ | |
16 | )''', re.VERBOSE) | |
17 | ||
18 | text = pyperclip.paste() | |
19 | ||
20 | website_matches = website_regex.findall(text) | |
21 | ||
22 | all_matches = [] | |
23 | ||
24 | for item in website_matches: | |
25 | all_matches.append(item[0]) | |
26 | line = '\n' | |
27 | ||
28 | ||
29 | combined = line.join(all_matches) | |
30 | pyperclip.copy(combined) |