Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. import re
  2.  
  3. pattern = re.compile(r"I am (d{1,2}) .*", re.IGNORECASE)
  4.  
  5. text = "i am 32 years old"
  6.  
  7. if re.match(pattern, text):
  8. print(
  9. re.sub(pattern, r"Your are 1 years old.", text, count=1)
  10. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement