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'.
"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,
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