In an identifier, commas act as separators for the parameters.


Means: $1 = one, $2 = two

So in other words, the expression that you are using has comma's in the regex, which are seen as param delimiters. I don't really understand why you didn't figure that out, because you should get a * Invalid parameters: $fline, error message when issuing your $fline code on a channel.

If you want to use comma's in an identifier, either use $chr(44), or put the expression in a variable first, and then pass the variable to the parameters.

So instead of doing:

//echo -a $mid(this, is a test,1,3), which gives: * Invalid parameters: $mid

You do:

//var %text = this, is a test | echo -a $mid(%text,1,3), which gives "thi"

In this specific case of a regex, you can just change \S{0,2} to something like: \S?\S?, thus avoiding the comma in {0,2}, or you can put brackets around it like: (\S{0,2}) which makes mIRC interpret the comma as part of the regex expression. Note that when you use the brackets like that, it makes the pattern inside it captured, which means you can reference it with \<N> and can reference it with $regml(N). It is slightly, yet not noticably more efficient to use the uncapturing form (?:\S{0,2}).

Btw, if you use the x modifier, it will ignore whitespace in your regex pattern except for whitespace that is inside a character class, inside { }, or inside \Q\E, or escaped with \, so that you can get rid of that $+. Of course, it doesn't really matter much, but I thought I'd mention it anyway.

//echo -a $regex(ab,/a b/x)
--> 1