fork download
  1. import re
  2. titles = [r'Car Model Variation 90-92',r'Car Model Variation 90']
  3. year = r'1990|1991|1992|1993|1994|1995|1996|1997|1998|1999'
  4. p = "|".join([x[2:] for x in year.split("|")])
  5. rx = re.compile(rf'(?s)\b(?:{p})\b.*?\b(?:{p})\b')
  6.  
  7. for title in titles:
  8. print ( f"'{title}' =>", bool(rx.search(title)) )
Success #stdin #stdout 0.02s 9512KB
stdin
Standard input is empty
stdout
'Car Model Variation 90-92' => True
'Car Model Variation 90' => False