Re: count string replace occurances

2005-06-13 Thread William Park
Xah Lee <[EMAIL PROTECTED]> wrote: > if i have > mytext.replace(a,b) > how to find out many many occurances has been replaced? If 'a' and 'b' are different length, - Count the string length, before and after. The difference should be multiple of difference between length of 'a' and 'b'.

Re: count string replace occurances

2005-06-12 Thread George Sakkis
"Jeff Epler" wrote: > On Sun, Jun 12, 2005 at 04:55:38PM -0700, Xah Lee wrote: > > if i have > > mytext.replace(a,b) > > how to find out many many occurances has been replaced? > > The count isn't returned by the replace method. You'll have to count > and then replace. > > def count_replace(a, b,

Re: count string replace occurances

2005-06-12 Thread Jeff Epler
On Sun, Jun 12, 2005 at 04:55:38PM -0700, Xah Lee wrote: > if i have > mytext.replace(a,b) > how to find out many many occurances has been replaced? The count isn't returned by the replace method. You'll have to count and then replace. def count_replace(a, b, c): count = a.count(b) retur

count string replace occurances

2005-06-12 Thread Xah Lee
if i have mytext.replace(a,b) how to find out many many occurances has been replaced? Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/python-list