Advertisement
Guest User

new

a guest
Feb 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import re
  2.  
  3. line = "Cats are smarter than dogs"
  4.  
  5. matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I)
  6.  
  7. if matchObj:
  8. print ("matchObj.group() : ", matchObj.group())
  9. print ("matchObj.group(1) : ", matchObj.group(1))
  10. print ("matchObj.group(2) : ", matchObj.group(2))
  11.  
  12. else:
  13. print ("No match!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement