I have a file with millions of retweets – like this:
RT @Username: Text_of_the_tweet
I just need to extract the username from this string. Since I'm a total zero when it comes to regex, sometime ago here I was advised to use
username = re.findall('@([^:]+)', retweet)
This works great for the most part, but sometimes I get lines like this:
RT @ReutersAero: Further pictures from the #MH17 crash site in in Grabovo, #Ukraine #MH17 - @reuterspictures (GRAPHIC): http://t.co/4rc7Y4…
I only need "ReutersAero" from the string, but since it contains another "@" and ":" it messes up the regex, and I get this output:
['ReutersAero', 'reuterspictures (GRAPHIC)']
Is there a way to use the regex only for the first instance it finds in the string?
