- #!/usr/bin/python
- import re
- line = "Cats are smarter than dogs"
- line2 = "Uploading file...\nRaspberry Pi YouTube Upload' (video id: ZiWUDt_n3VI) was successfully uploaded."
- matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I|re.MULTILINE)
- if matchObj:
- print "matchObj.group() : ", matchObj.group()
- print "matchObj.group(1) : ", matchObj.group(1)
- print "matchObj.group(2) : ", matchObj.group(2)
- else:
- print "No match!!"
Raw Paste