【发布时间】:2011-10-01 19:09:26
【问题描述】:
我想查找出现在关键字(由我指定和搜索)之后出现的单词并打印出结果。我知道我想用正则表达式来做,我也试过了,像这样:
import re
s = "hi my name is ryan, and i am new to python and would like to learn more"
m = re.search("^name: (\w+)", s)
print m.groups()
输出只是:
"is"
但我想获取“名称”之后的所有单词和标点符号。
【问题讨论】:
标签: python regex matching keyword