mIRC Homepage
Posted By: zorin Help with parsing/replacing text - 02/01/07 07:02 AM
I have some text followed by a space and a number, now what I want to do is replace all the text so that only the number is left.. Anyone have a easy solution? smile
Posted By: Riamus2 Re: Help with parsing/replacing text - 02/01/07 02:04 PM
If the number is always a certain number of digits (for example, 2 digits), you can use $right(%text,2) to get it.

If it varies, then using tokens would be the best way.

If that is the only space, you can use:
$gettok(%text,2,32)

If it's always the same number of spaces (let's say there are 4 spaces in the text, then a space, then the number), you can use:
$gettok(%text,6,32)

(that 6 is 1 more than the number of spaces).

Or, if you have a random number of spaces and the number is not always the same number of digits, you can use:
$gettok(%text,$gettok(%text,0,32),32)

That will always grab the last spaced item, no matter how many spaces there are.
Posted By: Mpdreamz Re: Help with parsing/replacing text - 02/01/07 04:30 PM
//echo -a $regsubex(34sd 4sd5 sd 6 76,/.*?(\d|\s).*?/g,\t)
will return
"34 45 6 76"

it strips everything but spaces and digits.

Sorry Riamus this is not a reply to you smile
Posted By: zorin Re: Help with parsing/replacing text - 02/01/07 05:30 PM
$gettok(%text,6,32) did the trick smile Thanks yall!
© mIRC Discussion Forums