grep

Command: grep


Description

"grep" is similar to the Unix command "grep".
It performs a regular expression match either on the lines of a
file or on the strings in an array of strings. A valid regular
expression must be passed as a string as second argument.

"grep" returns an array of matching lines or strings. It returns the
full lines or strings that matched. If not match was found the
empty array is returned.

Parameters

(filename) - name of the file to search for the pattern
[(string1) ...] - array of strings to search for the pattern
[(match1) ...] - result: array of matching strings

Author
R Kupper

Synopsis

(filename) (expression) grep -> [(line1) (line2) ...]
[(string1) (string2) ...] (expression) grep -> [(match1) (match2) ...]

References

Unix manpage for "regcomp"

Examples

[(hello) (world)] (^hell) grep -> [(hello)]
[(hello) (world)] (not in here) grep -> []
[(hello) (world)] () grep -> [(hello) (world)]
statusdict /prgdocdir get (LICENSE) joinpath (http) grep -> [(or visit http://www.nest-simulator.org)]

File
lib/sli/regexp.sli
Diagnostics

Raises /InvalidRegexError if the expression string is not a valid
regular expression.

FirstVersion
23-jul-2008

Availability
standard SLI

Options

By default "grep" uses extended regular expressions and performs
case sensitive matching on the single lines or strings. This
behaviour can be customized via the "SetOptions" command.

"grep" has the following options that can be set via the
"SetOptions" command:

/flags_regcomp (integer) - flags passed to the "regcomp" command.
Must be the logical AND of any of
regexdict::REG_{EXTENDED ICASE NOSUB NEWLINE}.
Default: REG_EXTENDED

/flags_regexec (integer) - flags passed to the "regexec" command.
Must be the logical AND of any of
regexdict::REG_{NOTBOL NOTEOL}.
Default: 0

Please read the Unix manpage for "regcomp" for explanation of these
flags.

To perform case insensitive matches add regexdict::REG_ICASE to
/flags_regcomp.