import re test = '4706TR Amsterdam'match = re.search(r"\b\d{4}[A-Z]{2}\b", test, re.IGNORECASE)if match: print(match.group())
Standard input is empty
4706TR
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!