mIRC Homepage
Posted By: clutz1572 question on $replace and $remove - 23/10/08 04:15 PM
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..
Posted By: RoCk Re: question on $replace and $remove - 23/10/08 04:20 PM

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
Posted By: clutz1572 Re: question on $replace and $remove - 23/10/08 04:39 PM
Aaah....


i see now, i didn't realize that... thanks a million RoCk.. I learned something laugh
Posted By: RoCk Re: question on $replace and $remove - 23/10/08 04:41 PM

Most welcome. smile
Posted By: clutz1572 Re: question on $replace and $remove - 07/12/08 05:00 PM
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..
Posted By: 5618 Re: question on $replace and $remove - 07/12/08 05:38 PM
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
Posted By: clutz1572 Re: question on $replace and $remove - 07/12/08 05:56 PM
i didn't even think of just switching the sub string... that seems to work well..

thanks
© mIRC Discussion Forums