Righteo then!
Here's a few pointers to get you started:
var %string = This is a long string of text
if (lon isincs %string) {
echo -a yup
}
--
if ($regex(%string, /lon/)) {
echo -a yup
}
These lines are roughly equivalent.
At it's most basic, the
$regex() matching will do partial string matches that are case sensitive. You can make it case insensitive if you want by adding an 'i' after the pattern markers (
/lon/i).
Now, to do full word matching like an
$istok(), we need to be a little more complex:
var %string = nick1|nick2|nick3
var %nick = nick2
if ($istok(%string, %nick, 124)) {
echo -a yup
}
--
if ($regex(%nick, /^( $+ %string $+ )$/i)) {
echo -a yup
}
This is as close as I could get to a simple
$istok().
We have to use the pipe symbol (|) as the separator for the regular expression, because we're basically saying "do you mach nick1 to this string, or that string, or the other string". The pipe is a regex 'atom' separator, and it's the only thing that can be used for it.
Now, that being said, we also only want to match the whole string, rather than just a partial string like we did above. That's what the
^ (carot) and
$ (dollar) symbols are. They're termed 'anchor'. The carot is the start-of-string anchor, whilst the dollar is the end-of-string anchor.
The long way of writing the pattern would be something like:
/^nick1$|^nick2$|^nick3$/i
But as you can see, it's fairly repetitive. As the start-end anchors are the same for all the middle bits, using parenthesis (
()) allows you to 'group' sub patterns to wrap it with other tricky bits.
This ability to group sub patterns is one of regular expressions strong points.
Now, all of this time, we're only doing simple string matches. We're not manipulating (
$regsub()/
$regsubex()) or even pulling out the matched patterns (
$regml()). Using the grouping parenthesis with these functions, and you can see this becoming a monstrous tool.
Yay..
Have a quick poke through these forums, there will be links to various tutorials, or just google 'regular expression tutorial mirc', or 'perlre' (which is the regular expression library that mIRC uses). If you get stuck (you probably will), feel free to poke us..
There are a few guys 'n girls on these forums who are very good with their regexp's