# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^[0-9a-zA-Z]{10}.*([A-Z\s]{16,})\\n"
test_str = ("\n\n\n"
"4nXQOweFyC\\x10HWANG SEAN SOJIN\\n\n"
"^[0-9a-zA-Z]{10}\\\\[0-9a-z]{3}([A-Z\\s]{3,})\\\\n\n\n"
"^[0-9a-zA-Z]{10}\\\\x10([A-Z\\s]{3,})\\\\n\n\n"
"^[0-9a-zA-Z]{10}\\\\x14([A-Z\\s]{3,})\\n\n\n"
"# 정의되어야 함\n\n"
"4nYBfE4dug\\x07GUO JIE\\n\n\n"
"4nYWf22CBO\\x08LI FULAN\\n\n\n\n"
"^[0-9a-zA-Z]{10}\\\\x08([A-Z\\s]{3,})\\\\n\n\n\n"
"4mfP1jNaF4\\x14광진실리콘(주)\\n\n\n\n"
"4nXckRULYB\\x0fCHANG LAI HSIEN\\n\n\n"
"0UN97Wa9oU\\t507030360A0130(\\x010\\x011\\x011\\x010\\x0202\\x011(\\x010(\\x010\\x01N\\x0b20년/20년\\x082021031860860\\x012\\x011\\x03B\\x011\\x01N\\x0820210318\\x0820210318\\x0820210318\\x132021-03-18 12:01:34\\x011\\x0fCHANG LAI HSIEN\\x132021-03-18 10:57:01\\x132021-03-18 10:57:14\\x02[메리츠화재] 모바일 전자서명 안내\\n\n\n"
"4nAjfKqh8i\\x0bQUAN CANXIE\\n\n\n"
"^[0-9a-zA-Z]{10}\\x0b(\\([가-힣].*)\\n\n"
"^[0-9a-zA-Z]{10}([A-Z가-힣\\s]{2,})\\\\n\n\n\n\n"
"4nXzVRFyIl\\tJIN GUANGMAN\\n\n\n\n"
"4nXzVRFyIl\\t김현수\\n\n\n"
"4nJcIVZHxD\\x0b(주)철마\\n\n"
"^[0-9a-zA-Z]{10}\\\\x0b(\\\\([가-힣].*)\\\\n\n"
"^[0-9a-zA-Z]{10}\\\\x0b(\\([가-힣].*)\\\\n\n\n\n\n\n"
"^[0-9a-zA-Z]{10}\\t([A-Z가-힣\\s]{2,})\\n\n\n\n\n"
"^[0-9a-zA-Z]{10}\\\\t([A-Z가-힣\\s]{2,})\\\\n\n\n"
"^[0-9a-zA-Z]{10}\\t([A-Z가-힣\\s]{2,})\\n")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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