TIM*_*MEX 0 python regex string
该字符串包含一个或多个"@"符号.这些符号中的一个或多个必须在其后面有一个字符(不是空格).
import re
my_regex = re.compile(r'@\S+')
Run Code Online (Sandbox Code Playgroud)
在\S类匹配任何非空白字符.如果您不想只使用字母数字字符,则可能需要使用\w.
然后,如果您想获得匹配的所有实例:
for match in my_regex.finditer(string_to_search):
# Do something with the MatchObject in 'match'
Run Code Online (Sandbox Code Playgroud)
有关详细信息,finditer请访问:http://docs.python.org/library/re.html#re.finditer