HELP: String manipulation question from a newbie

Aahz Maruch aahz at netcom.com
Fri Aug 18 15:52:27 EDT 2000


In article <woTm5.6423$6E.1523573 at ptah.visi.com>,
Grant Edwards <ge at nowhere.none> wrote:
>In article <399ABB08.85FF4B12 at VerizonWireless.com>, Bill Scherer wrote:
>>
>>import string
>>URL = string.replace(URL, 'body_', '')
>
>He only wanted to replace the first occurrence. string.replace()
>replaces all occurrences.

In that case:

URL = string.replace(URL, 'body_', '', 1)

(Read The Fine Manual.  ;-)
--
                      --- 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

Gun-toting Naderite / socialized medicine libertarian



More information about the Python-list mailing list