mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2006
Posts: 25
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: May 2006
Posts: 25
Hi all.

I'd like to know if is there any efficient way to do this thing:

I declare a variable, for example:

%var1 = ascript bscript cscript dscript

Now I have a string, %var2 = bscript890.

I need to compare if any token in %var1, is contained in %var2. I know I can use a while loop and compare each of tokens from var1, but I'd like to know if it could be done more simply smile

Thanx!


==================
Abstraction is art.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Assuming %var1 contains alphanumeric characters only (you can get away with using some others too), you can use this:
Code:
if $regex([color:red]%var2[/color],$+(/,$replace([color:blue]%var1[/color],$chr(32),|),/i)) {
  do stuff
}

Otherwise, you'd have to escape the characters that are considered special by regex. The simplest way for you would be to prefix each of those chars in %var1 with a backslash \.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: May 2006
Posts: 25
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: May 2006
Posts: 25
Very elegant smile thanks a lot!


==================
Abstraction is art.

Link Copied to Clipboard