mIRC Home    About    Download    Register    News    Help

Print Thread
#122120 06/06/05 01:24 PM
D
defiant
defiant
D
Got a question about the next:

(%text = 1,11,21)

$replace(%text,1,a) this returns a,aa,2a

However, i only want it to replace the 1, not the 1's in other tokens. eg:

$replace(%text,1,a) -> a,11,21

Is this possible with just an extra parameter? orsmt.. Or should i make some other alias around it, replacing it as i want it to be?

#122121 06/06/05 01:33 PM
M
mIRCManiac
mIRCManiac
M
$reptok(%text,1,a,1,44)

/help $reptok

#122122 06/06/05 03:20 PM
D
DaveC
DaveC
D
mIRCManiac gave you the best answer, but in case its a mass replace of all the "1" tokens, and assuming there are no spaces, as in there isnt "1,23, 1,1 ,45"
then you could do this (looks complex but isnt), you add a comma to the front and end of %text, then search for ",1," and replace it with ",a,", finally the $left($mid( is just to remove the lead and trailing commas

$left($mid( $replace($+($chr(44),%text,$chr(44)),$+($chr(44),1,$chr(44)),$+($chr(44),a,$chr(44))) ,2),-1)

There are all types of wierd things you can do if you know the limits of what might be in the data such as
If you know there are no control codes you could do this
Add bold ctrl-b to the start and end of %text, then replace each comma with boldcommabold, then replace bold1bold with boldabold, and finally strip all the bolds back out.
$strip( $replace($+(,%text,),$chr(44),$+(,$chr(44),),1,a))

These of course just save you a little time in not having to loop doing $reptok(%text,1,a,1,44) since that only does one occurance frown


Link Copied to Clipboard