strsplit                package:base                R Documentation

_S_p_l_i_t _t_h_e _S_t_r_i_n_g_s _i_n _a _V_e_c_t_o_r

_D_e_s_c_r_i_p_t_i_o_n:

     Split the strings in `x' into substrings according to the presence
     of substring `split' within them.

_U_s_a_g_e:

     strsplit(x, split)

_A_r_g_u_m_e_n_t_s:

       x: character vector, to be split.

   split: character string containing a regular expression to use as
          ``split''.  If empty matches occur, in particular if `split'
          has length 0, `x' is split into single characters.  If
          `split' is a vector, it is re-cycled along `x'.

_V_a_l_u_e:

     A list of length `length(x)' the `i'-th element of which contains
     the vector of splits of `x[i]'.

_S_e_e _A_l_s_o:

     `paste' for the reverse, `grep' and `sub' for string search and
     manipulation; further `nchar', `substr'.

_E_x_a_m_p_l_e_s:

     noquote(strsplit("A text I want to display with spaces", NULL)[[1]])

     x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
     # split x on the letter e
     strsplit(x,"e")

     unlist(strsplit("a.b.c", "."))
     ## [1] "" "" "" "" ""
     ## Note that `split' is a regexp!
     ## If you really want to split on `.', use
     unlist(strsplit("a.b.c", "\\."))
     ## [1] "a" "b" "c"

