Advertisement
DiYane

Extract the link

Sep 27th, 2023
1,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import re
  2.  
  3. pattern = r'((www)\.([A-Za-z0-9]+(\-[A-Za-z0-9]+)*(\.[a-z]+)+))'
  4. some_sentance = input()
  5. valid_urls = []
  6.  
  7. while some_sentance:
  8.     matches = re.finditer(pattern, some_sentance)
  9.     for match in matches:
  10.         valid_urls.append(match.group(1))
  11.     some_sentance = input()
  12. for valid_url in valid_urls:
  13.     print(valid_url)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement