From: Spencer Parker <inthefri...@gmail.com>
>Cc: tutor@python.org
>Sent: Wednesday, 31 March, 2010 20:30:56
>Subject: Re: [Tutor] simple search and replace...
>
>That was only a small example of a message...the message contains several
>elements. If I have the PID segment then I have OBR segment...an OBX, etc.
>So it would have to cycle through finding each element that is in the message
>till the end. I actually meant a list and not a dictionary...terminology
>confusion in my head.
>OK I suspected as much.
But if it's fixed patterns you can either do a replace()
in a loop over your patterns:
for pat in ['PID','OBR',....]
h7string = h7string.replace('\n'+pat, h7string)
Or even build a regex that does it all in one.
(But the regex could get complex quickly!)
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor