I compiled the following pattern
pattern = re.compile(
r"""
(?P<date>.*?)
\s*
(?P<thread_id>\w+)
\s*PACKET\s*
(?P<identifier>\w+)
\s*
(?P<proto>\w+)
\s*
(?P<indicator>\w+)
\s*
(?P<ip>\d+\.\d+\.\d+\.\d+)
\s*
(?P<xid>\w+)
\s*
(?P<q_r>.*?)
\s*\[
(?P<flag_hex>[0-9]*)
\s*
(?P<flag_char_code>.*?)
\s*
(?P<status>\w+)
\]\s*
(?P<record>\w+)
\s*
\.(?P<domain>.*)\.
""", re.VERBOSE
)
to work with this string
2/1/2014 9:34:29 PM 05EC PACKET 00000000025E97A0 UDP Snd 10.10.10.10 ebbe R Q [8381 DR NXDOMAIN] A (1)9(1)a(3)c-0(11)19-330ff801(7)e0400b1(4)15e0(4)1ca7(4)2f4a(3)210(1)0(26)841f75qnhp97z6jknf946qwfm5(4)avts(6)domain(3)com(0)
And it successfully works
In [4]: pattern.findall(re.sub('\(\d+\)', '.', x))
Out[4]:
[('2/1/2014 9:34:29 PM',
'05EC',
'00000000025E97A0',
'UDP',
'Snd',
'10.10.10.10',
'ebbe',
'R Q',
'8381',
'DR',
'NXDOMAIN',
'A',
'9.a.c-0.19-330ff801.e0400b1.15e0.1ca7.2f4a.210.0.841f75qnhp97z6jknf946qwfm5.avts.domain.com')]
The issue is that it takes so long in some cases, any idea how to enhance the pattern for consuming time.