Multiple string replacement...
Aahz Maruch
aahz at panix.com
Fri Sep 22 10:19:02 EDT 2000
In article <31575A892FF6D1118F5800600846864D5B113D at intrepid>,
Simon Brunning <SBrunning at trisystems.co.uk> wrote:
>
>This all works OK, except...
>
>I set up a ROT13 replacement set, which looks like:
>[['A', 'N'], ['B', 'O'], ['C', 'P'], ['D', 'Q'], ['E', 'R'], ['F', 'S'],
>['G', 'T'], ['H', 'U'], ['I', 'V'], ['J', 'W'], ['K', 'X'], ['L', 'Y'],
>['M', 'Z'], ['N', 'A'], ... and so on. The problem here is that after 'A'
>and been replaced by 'N', it gets replaced back again.
>
>Anyone got a cunning plan?
For this specific issue, just use string.translate(). For more complex
issues, you'll need to switch to regexes or parsers.
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Member of the Groucho Marx Fan Club --Aahz
More information about the Python-list
mailing list