fork download
  1. import re
  2.  
  3. test = '4706TR Amsterdam'
  4. match = re.search(r"\b\d{4}[A-Z]{2}\b", test, re.IGNORECASE)
  5. if match:
  6. print(match.group())
Success #stdin #stdout 0.02s 9688KB
stdin
Standard input is empty
stdout
4706TR