Newbie seeks help on case preserving substitutions
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Wed Jun 27 03:25:00 EDT 2001
Tue, 26 Jun 2001 09:35:22 +0200, Nicola Musatti <objectway at divalsim.it> pisze:
> My strings have two parts: an initial two letter code and a
> subsequent name. Those strings that are neither all uppercase
> nor all lowercase always have an uppercase code and a capitalized
> (i.e. first letter upper, all others lowercase) name.
So there are only three case forms. You can perform three passes over
each line, each pass being a case-sensitive replacement of constant
strings prepared before the loop.
This can be done without regexps, using .replace(old,new) method of
strings (or string.replace(s,old,new) in Python < 2.0).
Hej!
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list