PYTHON   17

regexp py

Guest on 25th August 2022 04:40:27 AM

  1. #!/usr/bin/python
  2. import re
  3.  
  4. line = "Cats are smarter than dogs"
  5. line2 = "Uploading file...\nRaspberry Pi YouTube Upload' (video id: ZiWUDt_n3VI) was successfully uploaded."
  6.  
  7. matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I|re.MULTILINE)
  8.  
  9. if matchObj:
  10.    print "matchObj.group() : ", matchObj.group()
  11.    print "matchObj.group(1) : ", matchObj.group(1)
  12.    print "matchObj.group(2) : ", matchObj.group(2)
  13. else:
  14.    print "No match!!"

Raw Paste


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