# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"Xpra(?<vcxXPRA>\s\d{1,2}\/\d{1,2}\/\d{1,2})\sF:(?<vcxXPRAfreqname>\w{1,9})\s(?<vcxXPRAfreq>\d{3},\d{3})\sTx\((?<vcxXPRAtxPTT>\d\d\d\d)\s(?<vcxXPRAtxPTTmin>\d{2,4}):(?<vcxXPRAtxPTTsec>\d{2,4})\)\sRx\((?<vcxXPRArxSQ>\d\d\d\d)\s(?<vcxXPRArxSQmin>\d{2,4}):(?<vcxXPRArxSQsec>\d{2,4})\);$"
test_str = ("VCX_Stat;31.07.2018 20:43:59;S;ATCC#3 V 3 0 VCX - SVS ACC Phone/vieint1044(1):366001->371701 Voc TRM:nrm.cl.clr T:0:19 CL: 42 PL: 42 CI: 0 CPT:4;\n"
"VCX_Stat;14.10.2018 23:40:13;S;INN#3 V 3 0 'inn2pat_1003' (4) Total: 0:29;\n"
"VCX_Stat;14.10.2018 23:39:57;S;ATCC#1 V 1 0 Xpra 8/1/1 F:MIL3 139,100 Tx(0000 00:00) Rx(0001 00:04);\n"
"VCX_Stat;14.10.2018 23:38:47;S;ATCC#2 V 2 0 VIE BRA/bravie0501:362999->999999 Voc REJ:unall.num. T:0:00 CL: 44 PL: 44 CI: 0 CPT:4;\n"
"VCX_Stat;14.10.2018 23:38:35;S;ATCC#1 V 1 0 VCX - SVS ACCFuKOR_/vieint1049(2):676135->661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:35;S;ATCC#1 V 1 0 INN - VIE__2MBit__/innvie1201(3):676135->661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:35;S;INN#3 V 3 0 INN2 - VOR_________/inn2vor_1005(2):676135->661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:35;S;INN#3 V 3 0 INN - VIE__2MBit__/innvie1201(3):676135->661635 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:23;S;INN#3 V 3 0 INN - VIE__2MBit__/innvie1201(3):676134->661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:23;S;ATCC#1 V 1 0 /Qsig2M 4/1/2(28):676134->661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:23;S;ATCC#3 V 3 0 /Qsig2M 4/1/1(28):676134->661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;\n"
"VCX_Stat;14.10.2018 23:38:23;S;ATCC#1 V 1 0 INN - VIE__2MBit__/innvie1201(3):676134->661634 Voc TRM:nrm.cl.clr T:0:09 CL: 8 PL: 8 CI: 0 CPT:3;")
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