home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / base / grep < prev    next >
Encoding:
Text File  |  1997-04-23  |  2.0 KB  |  64 lines

  1.     
  2.     _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
  3.     
  4.          grep(pattern, x, ignore.case=FALSE, extended=TRUE, value=FALSE)
  5.          sub(pattern, replacement, x,
  6.                  ignore.case=FALSE, extended=TRUE)
  7.          gsub(pattern, replacement, x,
  8.                  ignore.case=FALSE, extended=TRUE)
  9.     
  10.     _A_r_g_u_m_e_n_t_s:
  11.     
  12.          pattern : character string containing a regular expres-
  13.                    sion to be matched in the vector of character
  14.                    string vec.
  15.     
  16.                x : a vector of character strings where matches
  17.                    is sought.
  18.     
  19.      ignore.case : if FALSE, the pattern matching is case sensi-
  20.                    tive and if TRUE, case is ignored during
  21.                    matching.
  22.     
  23.         extended : if TRUE, extended regular expression matching
  24.                    is used, and if FALSE basic regular expres-
  25.                    sions are used.
  26.     
  27.            value : if FALSE, a vector containing the indices of
  28.                    the matches determined by grep is returned,
  29.                    and if TRUE, a vector containing the matching
  30.                    elements themselves is returned.
  31.     
  32.      replacement : a replacement for matched pattern in sub and
  33.                    gsub.
  34.     
  35.     _D_e_s_c_r_i_p_t_i_o_n:
  36.     
  37.          grep searches for matches to pattern given as its first
  38.          argument within the the vector of character strings
  39.          given as its second argument.
  40.     
  41.          sub and gsub perform replacement of matches determined
  42.          by regular expression matching.  The functions differ
  43.          only in that sub replaces only the first occurence of a
  44.          pattern whereas gsub replaces all occurences.
  45.     
  46.          The regular expressions used are those specified by
  47.          POSIX 1003.2, either extended or basic, depending on
  48.          the value of the extended argument.
  49.     
  50.     _N_o_t_e:
  51.     
  52.          This function is based on the regex regular expression
  53.          library written by Henry Spencer of the University of
  54.          Toronto.
  55.     
  56.     _S_e_e _A_l_s_o:
  57.     
  58.          match, pmatch.
  59.     
  60.     _E_x_a_m_p_l_e_s:
  61.     
  62.          grep("[a-z]", letters)
  63.     
  64.