fork download
  1. import re
  2. rx = re.compile(r'''
  3. ages\
  4. (\d+(?:\ years)?\ and\ (?:above|up))
  5. ''', re.VERBOSE)
  6.  
  7. string = '''
  8. 1) 120 lbs and is intended for riders ages 8 years and up. #catch : 8 years and up
  9. 2) 56w x 28d x 32h inches recommended for hobbyists recommended for ages 12 and up. #catch : 12 and up
  10. 3) 4 users recorded speech for effective use language tutor pod measures 11l x 9w x 5h inches recommended for ages 6 and above. #catch : 6 and above
  11. '''
  12.  
  13. matches = rx.findall(string)
  14. print(matches)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
['8 years and up', '12 and up', '6 and above']