# Command: grep

NEST HelpDesk | Command Index | NEST Quick Reference

Name:

    grep - extract lines matching a regular expression pattern

Synopsis:

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

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)]

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

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.

Diagnostics:

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

Availability:

    standard SLI

References:

      Unix manpage for "regcomp"

Author:

    R Kupper

FirstVersion:

    23-jul-2008

SeeAlso:

- regex_find
- regcomp
- regexec
- regexdict

Source:

    /opt/conda/conda-bld/nest_1524088722951/work/nest-2.14.0/lib/sli/regexp.sli

NEST HelpDesk | Command Index | NEST Quick Reference

© 2004 The NEST Initiative