mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2012
Posts: 5
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
Hello!
Just for fun, I'm trying to do an <x> is <y> detecting script, like with the XKCD bot. I can return which token the 'is' is, as a variable. So then I want to return the parameters between $3 and the 'is' - if IS is parameter 4, I want to return $3-4. If IS is parameter 7, I want to return $3-7.
I don't how to do this. :C I tried using a variable: $3-%var but that doesn't seem to work. Does anyone know a method for doing this? shocked
Thanks in advance!

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
It's probably easier/cleaner to use a regex. The following will isolate <x> and <y> for you.

Code:
on $*:text:/(.+) is (.+)/iS:#:{
  echo -ag <x> = $regml(1)
  echo -ag <y> = $regml(2)
}

Joined: Jun 2012
Posts: 5
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
I tried it, and it works fine, thanks smile
Regexes are new to me so I did a bit of reading on them, but I'm still confused as to what the / and the /iS is doing. smirk

Last edited by dreadofmondays; 03/06/12 09:09 AM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
/ is used to surround the actual regex, i and S are modifiers for case insensitivity and to strip out control codes (color, bold, etc.)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just so you are aware, you can use a variable the way you were trying, but you have to include a space before the variable and use $gettok()...

$gettok($1-,3- %var,32)


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2012
Posts: 5
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jun 2012
Posts: 5
Ah, thanks, that's what I wanted to know. smile


Link Copied to Clipboard