Python Regular Expression example

前端 未结 9 1537
天命终不由人
天命终不由人 2020-12-08 10:04

I want to write a simple regular expression in Python that extracts a number from HTML. The HTML sample is as follows:

Your number is 123
         


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 10:21

    import re
    m = re.search("Your number is (\d+)",
          "xxx Your number is 123  fdjsk")
    if m:
        print m.groups()[0]
    

提交回复
热议问题