# $str.grep

Emulates the GNU Regular Expression Parser

Usage

    $str.grep(<match>,<strings>[,<flags>])

Description

Returns an array with the elements of <strings> which match the string <match>. <flags> can be any combination of the characters 's','w' and 'r'.
If the flag 'w' is specified then <match> is assumed to be a wildcard regular expression (with * and ? wildcards). If the flag 'r' is specified then <match> is assumed to be a standard regular expression. If none of 'w' and 'r' is specified then <match> is treated as a simple string to be searched in each element of the <strings> array. 'r' takes precedence over 'w'. If the flag 's' is specified the matches are case sensitive.
Note that since almost any other variable type can be automatically cast to an array, then you can use this function also on scalars or hashes.

Syntax Specification

    <array> $str.grep(<match:string>,<strings:array>[,<flags:string>])

Examples

        # Find all the nicknames starting with the letter A or a
        echo $str.grep("^a",$chan.users,"r")
        # Find the current CPU speed (on UNIX like machines only)
        echo $str.grep("MHz",$str.split($lf,$file.read("/proc/cpuinfo")))
        # simply check if the specified string matches a regular expression
        # (this in fact is a little tricky, but you will probably not notice it :D)
        if($str.grep("[st]+","test string","r"))echo "Yeah, it matches!"

See also
$array

Index, Functions

KVIrc 3.4.2 Documentation
Generated by ports-amd64 at Fri Feb 26 06:10:29 2010