Search for Pattern in Text

DESCRIPTION:

Searches for a text pattern as described by a regular expression in a vector of character strings.

USAGE:

oldGrep(pattern, text) 

REQUIRED ARGUMENTS:

pattern
character string specifying the pattern to search for.
text
vector of character strings.

VALUE:

numeric vector telling which elements of text matched pattern. It returns numeric(0) when there are no matches. In all cases, the return value can be used as a subscript to retrieve the matching elements of text .

DETAILS:

This function provides access to an old version of the grep function, which interprets pattern differently on different platforms. The current grep function is exactly the same on all platforms, and is the preferred version to use.

This function interprets pattern almost the same as grep and regexpr , except that it allows pattern to be a vector of character strings, or to contain the "|" character to indicate multiple patterns.

SEE ALSO:

, , , .

EXAMPLES:

state.name[ oldGrep("ia$", state.name) ] 
  # find state names that end in "ia" 
state.name[ oldGrep("ia$|^M", state.name) ] 
  # find state names that end in "ia" or start with "M" 
  # Note matching is not the same as in ls 
state.name [oldGrep ("^Ne", state.name)] 
  # returns all states beginning with "Ne" 
state.name [oldGrep ("Ne[a-e]", state.name)] 
  # returns Nebraska