Please Disable Ad-Block To View This Website.

If you block ads, this site can not survive!

Ads are very minimal for registered users. If you don't have an account please register now!

 Full Scripts
 MTS Themes
 File Queue
 Download mIRC
 Top Downloads
 Submit Form

Site Search

Link to us!

Home | Comments:
Regex Tutorial by Trystan
A small tutorial on the $regex() function in mIRC along with some examples of usage

Submitted Review Author's Updates

There is no review for this file yet.
There are no update notes.


  Mode:    Create New Post

tomalak16Sep 20, 2005 12:30PM
ARGH!! Where are your regex delimiters! Leaving them out can lead to some very esoteric problems that would confound any users following this tutorial who weren't aware of the possible problems.

For example, what happens if you are using a regex "moo" ? It should be "/moo/" but to follow your example here it is not.

The first letter is 'm', which the Regex Engine expects to be a prefix before the first delimiter.

Now, if you were to do "m/moo/", the Engine looks at the delimiter '/' and sees you have a 'm' before it. This instructs it that in fact, the '/' can be changed to any character, whereas usually it has to be a '/'. So it takes the character after 'm' to be the delimiter. This means you can do "m|moo|" and it is essentially the same as "/moo/".

But our regex doesn't have delimiters, it is "moo". The Engine looks at the first letter and it sees a 'm', therefore it assumes the next character is a desired setting for a delimiter to use. The 'o' becomes a delimiter. So "moo" is the same as "m||" or "m//" or even just "//". An empty regex. And it won't match anything.

Now, for anyone who doesn't realise this sort of behaviour is to be expected, they would spend days on end trying to figure out why their perfectly valid regex 'moo' wasn't matching anything. And it's all because they didn't use delimiters: "/moo/".

Your tutorial is very good; hats off to you for doing it, it makes things very clear and easy to understand. Great stuff..... But you omit delimiters throughout and that is heresy against Regexes! Sorry.

tomalak16Sep 20, 2005 12:31PM
My example 'moo' may not be entirely accurate. There's something along those lines though... I'll see if I can dig it up out of my #mIRC logs at some point.

FiberOPticsSep 20, 2005 12:59PM
It's accurate.

$regex(a,moo) is the same as $regex(a,//) which both match.

Create New Post

You must be logged in to post messages.