我想找到关键字后面出现的单词(由我指定和搜索)并打印出结果.我知道我想使用正则表达式来做它,我也尝试过,像这样:
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()
Run Code Online (Sandbox Code Playgroud)
输出只是:
"is"
Run Code Online (Sandbox Code Playgroud)
但是我希望得到"名字"这个词之后的所有单词和标点符号.