--- Devon McCormick <[EMAIL PROTECTED]> wrote:
> Recent correspondence alerted me to the existence of an
> existing standard J function that I ought to use in place of a
> version I wrote. However, on reflection, I thought of a case
> where the two are not equivalent:
>
> ('AA';'B') stringreplace 'AAA'
> BA
> ('AA';'B') replace 'AAA'
> BB
>
> The latter simultaneously replaces both instances of "AA"
> (the instance starting at position 0 and the one at position 1)
> with "B"; the former is apparently replacing serially so doesn't
> see the second, overlapping occurrence of "AA".
>
> Does anyone have a thought to which behavior is "correct"
> or at least better?
JavaScript:
'AAA'.replace('AA','B')
BA
Python:
>>> "AAA".replace("AA","B")
'BA'
____________________________________________________________________________________
Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm