# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"^([a-zA-Z0-9-]{1,})>(.*?)[,](.*){1,},(qA[CXUoOSrRiZI]),(.+){1,}:"
test_str = ("# aprsc 2.1.13-g79b6c3e\n"
"# logresp WV6L unverified, server FIRST\n"
"KG6DMY-9>APAT51,RCHFLD,WIDE1*,qAR,ABAJO:!3846.80N/11205.07W&261/000/A=005347I'm Charles. 146.640 - pl 100\n"
"N3FAA>APRS,TCPIP*,qAC,AMBCWOP-2:@062011z3447.10N/11816.47W_049/001g002t053r000p001P001h57b10216L412AmbientCWOP.com\n"
"KM6WSX>APX219,N6EX-4*,qAR,KELLER:=3405.98N/11736.25W-/A=001105/\n"
"K7EDT-S>APDG01,TCPIP*,qAC,K7EDT-GS:;K7EDT B *062011z3322.32ND11148.72WaRNG0001/A=000010 440 Voice 443.12500MHz +0.0000MHz\n"
"RUTH>APNX02,WIDE3-3,qAR,N7GWT:!3918.75NS11505.39W#PHG58306/W3,NVn,N7GWT, Kimberly Pk, Nv\n"
"KD6FEE>APFII0,qAC,APRSFI:@201141h3343.14N/11747.18W[178/000/A=000108Stormprobe | KD6FEE@arrl.net!w5X!\n"
"XE2BNC-1>APMI06,WIDE2-2,qAR,XE2SI-10:@070122z3218.82N/11639.92WnPHG59304/CREBC Cerro Bola \n"
"N4RDZ-9>S3SWXY,W7DXJ-12,WIDE1,W6SCE-11*,WIDE2,qAR,N2GTR-2:`*)p{k>/`\"7/}_%\n"
"SQUAW>APN391,qAO,PVALY:!3428.16NS11152.56W#PHG3000/W3,AZn SQUAW PEAK DIGI 6479 FT W7EI\n"
"W7JLW>APRS,TCPIP*,qAC,T2CSNGRAD:@062013z3240.80N/11425.20W_049/003g007t062r000p000P000h44b10221eCumulusDsVP\n"
"K6CMG-7>APDR16,TCPIP*,qAC,T2FINLAND:=3404.28N/11728.09Wu359/002/A=000973 up to no good. \n"
"KC6JPG-D>APDG03,TCPIP*,qAC,KC6JPG-DS:!3407.92ND11733.37W&/A=000000440 MMDVM Voice 426.50000MHz +0.0000MHz, APRS for DMRGateway\n"
"KG5SWO>APRS,TCPIP*,qAC,AMBCWOP-2:@062011z3803.83N/12039.19W_151/000g000t054r000p000P000h60b10251L264AmbientCWOP.com\n"
"K0RNA-9>S3TVSQ,WIDE1-1,WIDE2-1,qAR,AG7GK-2:`(0Vm-6k/`\"8p}Encore Floors -Blue F-150 - Rich-Love,Peace,& Chicken Grease_%\n"
"KG6DMY-9>APAT51,RCHFLD,BACON,WIDE1*,qAR,ABAJO:!3846.80N/11205.07W&261/000/A=005347I'm Charles. 146.640 - pl 100\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