On 04/01/10 06:51, ALAN GAULD wrote:
> 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!)
Or even write a "regex precompiler" that converts a list of items to
search into regex string (read: '|'.join(keywords)). That may be
necessary depending on the complexity of your queries and your
clash-handling scenario (what would you like to happen if your
replacement string contains another string in the keywords?).
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor