fork download
  1. import re
  2. String1 = " I have total exp of 10-11 years. This includes 15 years in SAS and 5 years in python. I also have 8 months of exp in R programming."
  3. reg = r'\b\d{1,2}(?:\D+\d{1,2})?\D+(?:year|month)s?\b'
  4. print(re.findall(reg, String1))
  5.  
Success #stdin #stdout 0.02s 27728KB
stdin
Standard input is empty
stdout
['10-11 years', '15 years in SAS and 5 years', '8 months']