mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 423
C
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..

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

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

Joined: Aug 2004
Posts: 423
C
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

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Most welcome. smile

Joined: Aug 2004
Posts: 423
C
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..

Joined: Jun 2007
Posts: 933
5
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

Joined: Aug 2004
Posts: 423
C
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


Link Copied to Clipboard