PYTHON   31

regexp2 py

Guest on 25th August 2022 04:41:22 AM

  1. #!/usr/bin/python
  2. import re
  3.  
  4. line = "Uploading...\n'Raspberry Pi YouTube Upload' (video id: ZiWUDt_n3VI) was successfully uploaded."
  5.  
  6. matchObj = re.match( r"[^\(]*\(video id\: ([0-9a-zA-Z_-]*)\)", line, re.M|re.I|re.MULTILINE)
  7.  
  8. if matchObj:
  9.    print "matchObj.group() : ", matchObj.group()
  10.    print "matchObj.group(1) : ", matchObj.group(1)
  11. else:
  12.    print "No match!!"

Raw Paste


Login or Register to edit or fork this paste. It's free.