import re
regex = re.compile(r"\b[A-Z]{2}\b", flags=re.MULTILINE)
test_str = ("EFS Web 2.1.17\n"
"Corresponding to\n"
"1 102742238 CN A 2012-10-17 ZTE USA Inc. US20130094411A1\n"
"3 20150318972 2015-11-05 Zhang et al.\n"
"2 20130128860 2013-05-23 Zhang\n"
"1 20130094411 2013-04-18 Zhang\n"
"EFS Web 2.1.17\n"
"Examiner Signature Date Considered\n"
"3rd Generation Partnership Project; Technical Specification Group Radio Access Network; Evolved Universal\n"
"1 Terrestrial Radio Access (E-UTRA); Physical channels and modulation (Release 12), 3GPP TS 36.211 V12.7.0\n"
"fONAR_ NAN 12R nanac\n"
"vs Corresponding to\n"
"4 2014110837 WO Al 2014-07-24 Fujitsu Ltd. et al. US20150318972A1\n"
"3 2014107012 WO Al 2014-07-10 LG Electronics Inc.\n"
"; Corresponding to\n"
"2 103120006 CN A 2013-05-22 ZTE Corporation US20130128860A1 A fg FG ddDF dFGg A1 AL Al\n"
"EFS Web 2.1.17\n"
"| |\n"
"pore !")
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