[REBOL] Re: removing a character with replace - was: RE: [REBOL]
From: louisaturk:coxinet at: 6-Nov-2002 16:35
At 01:33 AM 11/7/2002 +1100, you wrote:
>Louis,
>
> > >Actually, Louis probably wants this:
> > >
> > > replace/all first x #"=FF" ""
> >
> > Actually I first tried:
> >
> > replace/all "replace/all x "=FF" ""
> >
> > but since it didn't work (because of the square brackets I overlooked), I
> > tried searching for characters instead of strings.
> >
> > You did not mean to put "first" in your example, right?
>
>I did mean it. That's in the case where, for example:
>
> x: ["a string"]
>
>We needed to modify the first element in the block.
>
> >> replace first x "a" "abc"
> == "abc string"
> >> x
> == ["abc string"]
I just tested again. At the console I get:
>> x: ["aaaaaaa string"]
== ["aaaaaaa string"]
>> replace/all x "a" "s"
== ["aaaaaaa string"]
>> x
== ["aaaaaaa string"]
>> replace/all first "a" "s"
>> x: ["aaaaaaa string"]
== "sssssss string"
That is just as you said. When I run it as a script:
rebol []
x: ["aaaaaaa string"]
replace/all first x "a" "s"
It works also.
However, this script doesn't work:
rebol []
x: ["aaaaaaa string" "what is an apple good for"]
foreach l x [
replace/all first l "a" "s"
]
** Script Error: replace expected target argument of type: series
** Near: replace/all first l "a" "s"
But without first it works. What is happening?
Louis