views:

67

answers:

2

The string contains one or more "@" symbols. One or more of those symbols must have a character after it (not a space).

+5  A: 
import re
my_regex = re.compile(r'@\S+')

The \S class matches any non-whitespace character. If you'd prefer only alphanumeric characters, you might want to use \w instead.

Then, if you wanted to get all of the instances where it matched:

for match in my_regex.finditer(string_to_search):
    # Do something with the MatchObject in 'match'

More details on finditer are available here: http://docs.python.org/library/re.html#re.finditer

Amber
A: 
import re
pattern = re.compile(r'@+\S+')

This pattern follows the question's spec more closely: "one or more "@" symbols"

Tim McNamara