mIRC Home    About    Download    Register    News    Help

Print Thread
question on $replace and $remove #205448 23/10/08 04:15 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
hey guys..

i'm trying to remove spaces in a text and replace a character at the same time But, when i test it out the charcter i replace gets duplicated..

example:
//echo -a $replace($remove(hello $chr(124) mom,|),$chr(32),$chr(47))

results in this: hello//mom

what i wanna do is to remove the spaces and replace the pipe whith / which is $chr(47) i believe.. But, i only want one instance of the forward slash character...

can someone explain why thats happening and how to do it proper please if i'm not doing it correctly?

thanks in advance..

Re: question on $replace and $remove [Re: clutz1572] #205449 23/10/08 04:20 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

It's happening because you are replacing the spaces with the / character turning this <space>|<space> into this /|/ and then removing the | character which leaves only the double //.

Try one of these...

This removes the spaces altogether and then replaces | with /

//echo -a --> $replace($remove(hello $chr(124) mom,$chr(32)),|,/)
--> hello/mom

or

This just replaces <space>|<space> with /

//echo -a --> $replace(hello $chr(124) mom,$+($chr(32),|,$chr(32)),/)
--> hello/mom

Re: question on $replace and $remove [Re: clutz1572] #205450 23/10/08 04:39 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
Aaah....


i see now, i didn't realize that... thanks a million RoCk.. I learned something laugh

Re: question on $replace and $remove [Re: clutz1572] #205451 23/10/08 04:41 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

Most welcome. smile

Re: question on $replace and $remove [Re: clutz1572] #207133 07/12/08 05:00 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
i have another question on this now..

for some reason the format changed... and now i'm getting a error:
Break: evaluation error (line 28, script4.mrc)

which is this:
%somevar = $+($chr(3),04,$replace($remove($wildtok(%temp,{*},2,58),{,},$chr(32)),|,/))


the format switch to : {hello | mom}

//echo -a $+($chr(3),04,$replace({hello | mom},|,/,{,[,},]))

but, i get a replace error... so i do this.. {hello $chr(124) mom}

and i get this result... {hello | mom} | / [ ]

how can i fix this so it so my result becomes hello/mom again... i'm kinda stumped..

Re: question on $replace and $remove [Re: clutz1572] #207134 07/12/08 05:38 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Well, something REALLY funky is going on due to the { } chars in the substring section of the $replace identifier.
You'll get a successful $replace if you switch { and } for $chr(123) and $chr(125) (only needed in the substring section).

Something like $eval({,0) works too but that's just too ugly if you ask me. ;P

Re: question on $replace and $remove [Re: 5618] #207135 07/12/08 05:56 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
i didn't even think of just switching the sub string... that seems to work well..

thanks