mIRC Homepage
Posted By: Erebus Variables in regular expression - 30/03/05 08:49 PM
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
Posted By: FiberOPtics Re: Variables in regular expression - 30/03/05 08:54 PM
Use $eval in the matchtext part.

Example: on $*:text:$($+(/,$me,/)):*: ..
Posted By: Erebus Re: Variables in regular expression - 30/03/05 09:11 PM
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
Posted By: tidy_trax Re: Variables in regular expression - 30/03/05 09:23 PM
Code:
on $1:text:$($+(/,$me,\54?) test/):#:/echo It worked
© mIRC Discussion Forums