home *** CD-ROM | disk | FTP | other *** search
-
- _P_a_t_t_e_r_n _M_a_t_c_h_i_n_g _a_n_d _R_e_p_l_a_c_e_m_e_n_t
-
- grep(pattern, x, ignore.case=FALSE, extended=TRUE, value=FALSE)
- sub(pattern, replacement, x,
- ignore.case=FALSE, extended=TRUE)
- gsub(pattern, replacement, x,
- ignore.case=FALSE, extended=TRUE)
-
- _A_r_g_u_m_e_n_t_s:
-
- pattern : character string containing a regular expres-
- sion to be matched in the vector of character
- string vec.
-
- x : a vector of character strings where matches
- is sought.
-
- ignore.case : if FALSE, the pattern matching is case sensi-
- tive and if TRUE, case is ignored during
- matching.
-
- extended : if TRUE, extended regular expression matching
- is used, and if FALSE basic regular expres-
- sions are used.
-
- value : if FALSE, a vector containing the indices of
- the matches determined by grep is returned,
- and if TRUE, a vector containing the matching
- elements themselves is returned.
-
- replacement : a replacement for matched pattern in sub and
- gsub.
-
- _D_e_s_c_r_i_p_t_i_o_n:
-
- grep searches for matches to pattern given as its first
- argument within the the vector of character strings
- given as its second argument.
-
- sub and gsub perform replacement of matches determined
- by regular expression matching. The functions differ
- only in that sub replaces only the first occurence of a
- pattern whereas gsub replaces all occurences.
-
- The regular expressions used are those specified by
- POSIX 1003.2, either extended or basic, depending on
- the value of the extended argument.
-
- _N_o_t_e:
-
- This function is based on the regex regular expression
- library written by Henry Spencer of the University of
- Toronto.
-
- _S_e_e _A_l_s_o:
-
- match, pmatch.
-
- _E_x_a_m_p_l_e_s:
-
- grep("[a-z]", letters)
-
-