mIRC Home    About    Download    Register    News    Help

Print Thread
#136976 06/12/05 03:09 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
Hi, i'll begin from the end :tongue: "use it on channel"

/fnick nick
this one works
alias fnick { filter -gwf $active nul /^\S{0,2} $+ $1>\s.+/i | echo 2 -a * $1 wrote $filtered $filtered line(s) }

$fnick(nick)
this one doesnt works at all
alias fnick return $1 wrote $fline(#,/^\S{0,2} $+ $1>\s.+/i,0,3) line(s)

#136977 06/12/05 03:37 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
In an identifier, commas act as separators for the parameters.

$myident(one,two)

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


Gone.

Link Copied to Clipboard