Skip to content

Instantly share code, notes, and snippets.

@cmcavoy
Created October 14, 2009 15:12
Show Gist options
  • Save cmcavoy/210144 to your computer and use it in GitHub Desktop.
Save cmcavoy/210144 to your computer and use it in GitHub Desktop.
message = 'chris is cool http://www.extjs.com/blog/2009/10/08/ext-js-designer-preview/ chris is cool'
url = 'http://www.extjs.com/blog/2009/10/08/ext'
new_url = 'http://bit.ly/QvMEU'
print message.replace(url, new_url) # 'chris is cool http://bit.ly/QvMEU-js-designer-preview/ chris is cool'
url_match = r'.*(http://[a-zA-Z0-9_.?=&/]*)'
m = re.match(url_match, message)
print m.groups()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment