Finding words after keyword in python

后端 未结 9 1906
清酒与你
清酒与你 2020-12-08 20:19

I want to find words that appear after a keyword (specified and searched by me) and print out the result. I know that i am suppose to use regex to do it, and i tried it out

9条回答
  •  [愿得一人]
    2020-12-08 21:03

    What you have used regarding your output:

    re.search("name (\w+)", s)
    

    What you have to use (match all):

    re.search("name (.*)", s)
    

提交回复
热议问题