import re
regex = re.compile(r"\b[A-Z]+\d*\b", flags=re.MULTILINE)
test_str = ("Buveinės adresas: Konstitucijos pr. 20A, 03502 Vilnius\n"
"Telefonai:\n"
"1884 arba +370 5 268 4444 (Privatiems klientams)\n"
"1633 arba +370 5 268 4422 (Verslo klientams)\n"
"Faksas: (8 5) 258 2700\n"
"El. paštas: info@swedbank.lt\n"
"Įmonės kodas: 112029651\n"
"PVM mokėtojo kodas: LT120296515\n"
"Banko sąskaita: LT55 7300 0100 0000 0036\n"
"Banko kodas: 73000\n"
"SWIFT kodas: HABALT22")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html