# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^(?P<unit_type>SL|SV)(?P<unit_size>10|15|20|25|30)(?P<mounting_type>P|G)(?P<decompression_feature>A|B)(?P<cracking_pressure>1|2|3|4)(?P<sep_1>-)(?P<unit_series>4X)(?P<sep_2>/|=)(?P<pilot_valve>6U|)(?P<type_of_limit_switch>QM|)(?P<power_supply_of_limit_switch>G24|)(?P<sep_3>/|)(?P<seal_material>M|V|)(?P<sep_4>/|)(?P<surface_coating>J3|)(?P<pipe_port>/12|)(?P<additional_details>(.|[0-9])*)$"
test_str = ("SV20PB1-4X/V\n"
"SV10GA3-4X/V\n"
"SL20GB1-4X/M/12\n"
"SV30PB2-4X/V\n"
"SV20GA2-4X/V\n"
"SL30PB2-4X/V\n"
"SV20GB3-4X/M/12\n"
"SL20PB4-4X/V\n"
"SL10GA1-4X/V/12\n"
"SV20GB4-4X/V\n"
"SV20GA1-4X=M\n"
"SV20GB1-4X/M/12\n"
"SL20GA3-4X/V\n"
"SV20GA3-4X/M/12\n"
"SL30PB4-4X/V\n"
"SL20PA1-4X/MSO286\n"
"SV10GA2-4X/M/12\n"
"SL20GA1-4X/V/12\n"
"SL10PB1-4X/MSO286\n"
"SV30GB2-4X/V\n"
"SV30GA1-4X/V/12\n"
"SL30GA1-4X/V/12=\n"
"SV30PB4-4X/V\n"
"SL25GB3-4X/\n"
"SV10GA3-4X/M\n"
"SV10GB3-4X/M\n"
"SV10PA2-4X/V\n"
"SL10PA4-4X/V\n"
"SV10PB2-4X/M\n"
"SL10PB1-4X/V\n"
"SL10PA4-4X/M\n"
"SV10PB1-4X/V\n"
"SV10GB1-4X/M/12\n"
"SL10PB3-4X/M\n"
"SV10GB1-4X/V\n"
"SL10PA2-4X/M\n"
"SL10PA3-4X/M\n"
"SL10PB1-4X/M\n"
"SL10GA4-4X/M\n"
"SL10GB3-4X/M\n"
"SL10GA1-4X/M/12\n"
"SL10GA1-4X/V\n"
"SL10GA2-4X/M\n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/V\n"
"SL30GA2-4X/M/12\n"
"SL30PA1-4X/MSO286\n"
"SL30GA2-4X/V/12\n"
"SV20PA4-4X/V\n"
"SL30GB1-4X/V\n"
"SL30PA1-4X/MT\n"
"SV20GB1-4X/V/12\n"
"SL20GA4-4X/V\n"
"SL20GA1-4X/6U/M\n"
"SL20GA1-4X/6U/V\n"
"SV10PB3-4X/V\n"
"SV10PA4-4X/V\n"
"SL10PB3-4X/V\n"
"SV30PB1-4X/V\n"
"SV30PA3-4X/V\n"
"SL20PA2-4X/MT\n"
"SV10PA2-4X/M/J3\n"
"SV20PA2-4X/M/J3\n"
"SL30GA4-4X/V\n"
"SV25GB3-4X/V\n"
"SL30GA3-4X/6U/M\n"
"SL20GA3-4X/M/12\n"
"SL10PA1-4X/MT\n"
"SV10PA1-4X=M\n"
"SL30GA1-4X/6U/V\n"
"SL30PB3-4X/6UQMG24M-A08B10P12X99Y00\n"
"SV30GB1-4X/V\n"
"SL20PA1-4X/6U/M-A08B99T00P00X99Y00\n"
"SL20PA2-4X/6U/M-A08B99X99Y00\n"
"SL20PB3-4X/QMG24M\n"
"SL20PB3-4X/QMG24V\n"
"SL20PB3-4X/6UQMG24M-A08B99P00X99Y00\n"
"SL30PB3-4X/6UQMG24M-A08B99P00X99Y00\n"
"SL20GA3-4X/6U/M\n"
"SL30PB3-4X/6UQMG24M-A08B00P12X99Y00\n"
"SL20GA2-4X/6U/M\n"
"SL20GB2-4X/6U/M\n"
"SL20PB3-4X/6UQMG24M-A08B12P00X99Y00\n"
"SL30PA1-4X/6U/M-A08B99X99Y00\n"
"SL30PB3-4X/6UQMG24M-A08B30P00X99Y00\n"
"SL30PB3-4X/6UQMG24M-A08B12P00X99Y00\n"
"SV20GB2-4X/V\n"
"SL30GA1-4X/6U/M\n"
"SL30PA1-4X/6U/M-X00Y00-168\n"
"SV10GB1-4X=M\n"
"SL30PA2-4X/6U/M-X00Y00-168\n"
"SL30PA1-4X=V\n"
"SL30PB3-4X/6UQMG24M-A00B08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SL30GB4-4X/V\n"
"SV30GB3-4X/QMG24/V\n"
"SV10GA1-4X=M\n"
"SV20GB2-4X/V/12\n"
"SV20PA3-4X/M/J3\n"
"SL10PA1-4X/VJ3\n"
"SL30PB3-4X/6UQMG24M-A08B08P12X99Y00\n"
"SL10GA1-4X/M/J3\n"
"SL30GB3-4X/6U/V\n"
"SL20GB3-4X/6U/V\n"
"SL25GB3-4X/QMG24V\n"
"SL10GB3-4X/QMG24V\n"
"SV20GB3-4X/QMG24M\n"
"SV30PB2-4X/MSO286\n"
"SL20PB2-4X/M/J3\n"
"SL30GB3-4X/M/J3\n"
"SV10GB3-4X/QMG24V\n"
"SV20GA1-4X/M/J3\n"
"SL30GB2-4X/M/J3\n"
"SL20PA1-4X=M\n"
"SL20PB4-4X/6U/M-A08B99X99Y00\n"
"SV10PB3-4X/QMG24V\n"
"SL30PB3-4X/6UQMG24M-A08B20P20X99Y00\n"
"SL20PB3-4X/6UQMG24M-A08B20P20X99Y00\n"
"SL20PB3-4X/6UQMG24M-A08B08P00X99Y00\n"
"SL20PB2-4X=M\n"
"SV20PA1-4X=M\n"
"SL20PA1-4X/VJ3\n"
"SL20GA2-4X/V/12\n"
"SL10GA2-4X/V/12\n"
"SV10GB1-4X/V/12\n"
"SL30GB3-4X/M/12\n"
"SL30GB1-4X/M/12\n"
"SV20GB1-4X/V/12\n"
"SL15GB2-4X/12\n"
"SL15GB1-4X/12\n"
"SL15GA1-4X/V/12\n"
"SV20GB2-4X/M/12\n"
"SV30GB2-4X/M/12\n"
"SL15GB4-4X/V/12\n"
"SV30GB2-4X/V/12\n"
"SL30GB3-4X/V/12\n"
"SL20GB3-4X/12\n"
"SL20GA2-4X/12\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