Extracting a URL in Python


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import re
  2.  
  3. myString = "This is my tweet check it out http://tinyurl.com/blah"
  4.  
  5. print re.search("(?P<url>https?://[^\s]+)", myString).group("url")

URL: http://stackoverflow.com/questions/839994/extracting-a-url-in-python

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.