Match Strings to Regular Expression Patterns.

USAGE:

regMatch(x, table, extended=x)

REQUIRED ARGUMENTS:

x
character string data, each element to be matched against the regular expressions.
table
any number of strings, each a regular expression.

OPTIONAL ARGUMENTS:

extended
should the "extended" regular expressions be used, default = T. See note below.

VALUE:

A logical vector of the matches. If x has NAs these produce NA in the result. If x and table are not the same length, the shorter one is extended by replication.

REGULAR EXPRESSIONS:

These are character strings in a little language with meta-characters to match position in the string or classes of characters. See your local documentation for the shell command "grep" or any book on UNIX. The extended patterns allow some additional control. S-PLUS does not invoke any shell commands to process the matching; instead, the matching is done internally by calls to routines implementing the Posix standard definition of regular expressions.

SEE ALSO:

does similar matching, returns numeric indices of the match (nicer for a few matches in large data). Matching in returns or replaces the substring of the matching strings. Supplying a object as a subset expression is equivalent to applying and using the resulting logical subscripts. Also see for matching character strings to the strings in table.

EXAMPLES:

# find state names starting in "New" 
newStates <- regMatch(state.name, "^New ")