mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2003
Posts: 27
Z
zorin Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Mar 2003
Posts: 27
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

Last edited by zorin; 02/01/07 09:54 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
//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

Last edited by Mpdreamz; 02/01/07 04:31 PM.

$maybe
Joined: Mar 2003
Posts: 27
Z
zorin Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Mar 2003
Posts: 27
$gettok(%text,6,32) did the trick smile Thanks yall!


Link Copied to Clipboard