thanks to everybody.
i guess that the algorithm would be easier if it was known in advance that the string to substitute must have some specific property, say:
1) they all must start with "XYZ" 2) they all have the same length N (e.g. 5) like this: qweXYZ12asdXYZ1345XYZ ---> qweIWAS12asdIWAS1345XYZ bye -- http://mail.python.org/mailman/listinfo/python-list