Advertisement
Guest User

Untitled

a guest
Dec 28th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement