【发布时间】:2013-06-07 20:00:54
【问题描述】:
k = 'a bunch of data and then name ""Serpin-ps""'
print re.search(r'name\s""(\w+)""',k).group(1)
给予:
AttributeError: 'NoneType' object has no attribute 'group'
desired_output = 'Serpin-ps'
有道理,因为文本中有一个“-”。
有没有办法让正则表达式将“-”与所有其他字母数字字符结合起来?
【问题讨论】:
标签: python regex search attributeerror