[Tutor] RegEx [Was: Parsing iptables log files]

S A buc40@bemail.org
Wed, 4 Sep 2002 10:53:38 -0700


> Danny Yoo <dyoo@hkn.eecs.berkeley.edu> Amaya Rodrigo Sastre <arodrigo@genasys.com>cc: tutor@python.org
> Re: [Tutor] RegEx [Was: Parsing iptables log files]Date: Wed, 4 Sep 2002 10:44:57 -0700 (PDT)

>###
>sample_line = """Aug 17 20:41:55 martinika kernel: --logtrack-- IN=
>OUT=lo SRC=192.168.100.10 DST=192.168.100.10 LEN=60 TOS=0x00 PREC=0x00
>TTL=64 ID=0 DF PROTO=TCP SPT=43085 DPT=80 SEQ=307515611 ACK=0
>WINDOW=32767 RES=0x00 SYN URGP=0"""
>
>def getNameValuePairs(log_line):
>    anchor = '--logtrack--'
>    name_values_line = log_line[log_line.find(anchor)
>                                + len(anchor) + 1 :]
>    pairs = name_values_line.split()
>    return pairs
>
>if __name__ == '__main__':
>    print getNameValuePairs(sample_line)
>###
>

So this just slices everything past the anchor "--logtrack--" and then splits the string into a list at every whitespace?

Thanks.
SA


"I can do everything on my Mac that I used to do on my PC, plus alot more ..."

-Me

------------------------------------------------------------
Free, BeOS-friendly email accounts: http://BeMail.org/
BeOS News and Community: http://www.BeGroovy.com/


---------------------------------------------------------------------
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
---------------------------------------------------------------------