mIRC Home    About    Download    Register    News    Help

Print Thread
B
bapplander
bapplander
B
Hi,

$3 grabs the third word from the beginning of a line, but how can I
like invert it and grab the third word from the end ?

S
schaefer31
schaefer31
S
$gettok(one two three,-3,32) --> one

The - specifies to start from the end and go backwards and the 3 means the third word, so third word from the end. If you need to know how $gettok works in general, then look at /help $gettok in mIRC.

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
This is an option:

Code:
alias word-test {
  var %string = word1 word2 word3 word4 word5 word6 word7
  var %3rd-last-word = $gettok(%string,$calc($numtok(%string,32) - 2),32)
  echo -a This is the 3rd word from the end: %3rd-last-word
}


Usage: /word-test
Probably not the best way to do it, but it does work.

Edit, shaefers option is indeed a lot more efficient.

Last edited by OrionsBelt; 25/03/07 11:24 PM.

Link Copied to Clipboard