mIRC Home    About    Download    Register    News    Help

Print Thread
Variables in regular expression #115840 30/03/05 08:49 PM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
Hello again,

I apologise if this is obvious, but what I need is to be able to use variables inside regexp, but I just cant get it to work frown

A very simple example:

Code:
on $1:TEXT:/%botnick/:#:/echo It worked!
or
Code:
on $1:TEXT:/$me/:#:/echo It worked!


As I said, a very simple example, but hopefully you can see what I am trying to do. Unfortunately, I cant get it to work, but I'm not sure what I'm doing wrong. I've tried about every combination I could think of to no avail.

I've tried escaping the $ and % characters, trying both a variable storedin $ and % but no luck.

I'm sure I'm missing something obvious here, and would apreciate any help.

Thanks

Re: Variables in regular expression #115841 30/03/05 08:54 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Use $eval in the matchtext part.

Example: on $*:text:$($+(/,$me,/)):*: ..


Gone.
Re: Variables in regular expression #115842 30/03/05 09:11 PM
Joined: Mar 2005
Posts: 20
E
Erebus Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Mar 2005
Posts: 20
Thanks that's a great help, athough I dont quite understand how it works with the rest because with the eval in, it complicates it a bit more and I tried a bit of experimenting, but I'm still not certain. If you could just clarify this for me, I'd really apreciate it

This is what works without the eval and variables in, how could I replace Myname with $me (and the rest of the new code)?

on $1:text:/Myname,? test/:#:/echo It worked

I've tried doing it with the new code, but it doesnt work because of the commas and I'm not sure how to get around this.

Thanks again, I'm new to the mirc scripting language, so please bear with me frown

Re: Variables in regular expression #115843 30/03/05 09:23 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
on $1:text:$($+(/,$me,\54?) test/):#:/echo It worked


New username: hixxy