This is a regex version of the $findfile identifier.
Note that this identifier will take a good while to evaluate if there are lots of files in the folder, since it has to check EVERY file to see if it is a regex match. Works exactly the same as the normal $findfile, except that if you are specifying a command to perform on every match the $n identifiers will evaluate to the parameters you supplied in the alias, e.g. $1 will evaluate to whatever directory you specified. In place of these identifiers, you should use ~n
Ex. //echo Total: $ffreg($mircdir,/(mrc|ini)$/i,0,echo Match: ~1-) - echoes every .mrc and .ini file in the mIRC directory to the active window, then echoes the total number of .mrc and .ini files in the mIRC directory.
Note: ~n- is also supported and works the same as $n- would in $findfile
alias ffreg {
var %x = 1
var %c,%i = 0
:regstupid
while ( %x <= $findfile($1,*,0) ) {
if ( $regex($findfile($1,*,%x),$2) ) {
if ( $4 !iswm @* ) && ( $4 ) {
var %nc = $replace($findfile($1,*,%x),\,$chr(200))
.echo -q $chr(32) $regsub(param,$4,/(^|\s)\~(\d)($|\s|\-)/g,$chr(32) $+ $gettok(%nc,$iif($regml(param,3) == -,$regml(param,2) $+ -,$regml(param,2)),32),%com)
if ( %i == 0 ) {
inc %i 1
goto regstupid
}
$replace(%com,$chr(200),\)
}
inc %c 1
elseif ( $4 iswm @* ) {
aline $4 $findfile($1,*,%x)
}
if ( $3 ) && ( %c >= $3 ) {
return $findfile($1,*,%x)
halt
}
}
inc %x 1
}
return %c
}