You can try the following re.sub function to remove the URL link from your string,
>>> str = 'This is a tweet with a url: http://t.co/0DlGChTBIx' >>> m = re.sub(r':.*$', ":", str) >>> m 'This is a tweet with a url:'
It removes everything after the first character : and : in the replacement line adds : last.
This will print all characters that were just before the character :
>>> m = re.search(r'^.*?:', str).group() >>> m 'This is a tweet with a url:'
source share