mIRC Home    About    Download    Register    News    Help

Print Thread
#179896 30/06/07 12:12 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Code:
alias _Tokenize { 
  var %x = 1 
  while (%x <= $numtok($1-,32)) { 
    var %y = %y $+(04[01,%x,04,$chr(44),01,$gettok($1-,%x,32),04]) 
    inc %x 
  } 
  echo -s %y 
} 


Is there a way i can make that smaller perhaps using a regsubex guys?

pouncer #179899 30/06/07 12:55 AM
Joined: Mar 2003
Posts: 612
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
$numtok($1-,32) can be replaced with $0


billythekid
pouncer #179903 30/06/07 03:14 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Sure.

Code:
alias _tokenize { echo -s $regsubex($1-,/(\S+)/g,$+(04[01,\n,04,$chr(44),01,\t,04])) }

pouncer #179927 30/06/07 12:41 PM
Joined: May 2007
Posts: 89
T
Babel fish
Offline
Babel fish
T
Joined: May 2007
Posts: 89
If I correctly understood the objective, here's what can replace it.

Code:

Alias _Tokenize { Echo -s $regsubex($1-,/(\S+)/g,$+(04[01,\n,04,$chr(44),01,\1,04])) }




Explanations:

Pattern: /(\S+)/g means " unless a space is matched, continue to match " . So this method will locate one after the other, each word of the string.



tropnul
pouncer #179937 30/06/07 03:18 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Here's another method:
Code:
[code]alias _tokenize tokenize 32 $1 | scon -r var $(%b = %b ,) $!+(4[,$calc( $!numtok(%b,32) +1),4,$chr(44),, $* ,4]) | return %bn %b %
[/code]


Kind Regards, blink
pouncer #179938 30/06/07 03:36 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias _Tokenize { echo -s $regsubex($1-,/([^ ]+)/g,$+(04[01\n04,$chr(44),01\t04])) }

b1ink #179939 30/06/07 03:53 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Quote:
scon -r .. $* ..

Never use that method unless you know exactly what the input will be. It will double-evaluate the contents of $1-, so if there's external input on there, you open up a huge security hole.

Try "//echo -ag $_tokenize($!pi)" if you don't believe me.


Saturn, QuakeNet staff
Sat #179941 30/06/07 04:47 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Thanks. it depends on what you are trying to pass with the identifier. I just posted that for fun tbh


Kind Regards, blink
hixxy #179942 30/06/07 04:48 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
why not \S :P


Kind Regards, blink
b1ink #179943 30/06/07 04:53 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
\S matches any char except 'whitespace'. This term however includes not only normal spaces (char 32) but also tabs, cr, lf etc. Those are not displayed as spaces in mirc windows.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
b1ink #179944 30/06/07 05:28 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The other change I made is that you do not need to use $+ to separate \t and \n from other text in the replacement parameter of $regsubex.

hixxy #180004 02/07/07 05:36 AM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
mm nice


Kind Regards, blink

Link Copied to Clipboard