finding and returning a string with a specified prefix

Posted by tipu on Stack Overflow See other posts from Stack Overflow or by tipu
Published on 2010-06-02T09:21:57Z Indexed on 2010/06/02 9:23 UTC
Read the original article Hit count: 243

I am close but I am not sure what to do with the restuling match object. If I do

p = re.search('[/@.* /]', str)

I'll get any words that start with @ and end up with a space. This is what I want. However this returns a Match object that I dont' know what to do with. What's the most computationally efficient way of finding and returning a string which is prefixed with a @?

For example,

"Hi there @guy"

After doing the proper calculations, I would be returned

guy

© Stack Overflow or respective owner

Related posts about python

Related posts about string