mIRC Home    About    Download    Register    News    Help

Print Thread
Wildcard comparison between string-list of string #148732 10/05/06 11:58 AM
Joined: May 2006
Posts: 25
A
Abstract Offline OP
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.
Re: Wildcard comparison between string-list of string #148733 10/05/06 01:21 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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
Re: Wildcard comparison between string-list of str #148734 10/05/06 01:36 PM
Joined: May 2006
Posts: 25
A
Abstract Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: May 2006
Posts: 25
Very elegant smile thanks a lot!


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