By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

replace from end of string?

P: n/a
Hi all,

in writing my response to Mark Leeds' recent question about replacing
text at the end of a string, I was moved to wonder if it wouldn't it
be handy if the replace method of string instances did one of the

took a negative integer for count and interpreted that as replace the
absolute value of count many instance, but starting from the end of
the string, or,

had a default parameter from_end=False, such that if it were True,
replacements happened count many times, starting from the end?
I get that it isn't too much of a hassle to write a function to do
this (heck, *I* did it, so it cannot be too rough ;-). But, it seems a
common enough task to be a useful addition nevertheless. (And the
speed of the C implementation wouldn't hurt, either.)

Is there already a pre-rolled way to do this that I've overlooked? Or
some strong reason there oughtn't be?

Thanks, and best to all,

Brian vdB

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.