delimMatch               package:tools               R Documentation

_D_e_l_i_m_i_t_e_d _P_a_t_t_e_r_n _M_a_t_c_h_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     Match delimited substrings in a character vector, with proper
     nesting.

_U_s_a_g_e:

     delimMatch(x, delim = c("{", "}"), syntax = "Rd")

_A_r_g_u_m_e_n_t_s:

       x: a character vector.

   delim: a character vector of length 2 giving the start and end
          delimiters.  Currently, both must be single characters. 
          Future versions might allow for arbitrary regular
          expressions.

  syntax: currently, always the string '"Rd"' indicating Rd syntax
          (i.e., '%' starts a comment extending till the end of the
          line, and '\' escapes).  Future versions might know about
          other syntaxes, perhaps via "syntax tables" allowing to
          flexibly specify comment, escape, and quote characters.

_V_a_l_u_e:

     An integer vector of the same length as 'x' giving the starting
     position of the first match, or -1 if there is none, with
     attribute '"match.length"' giving the length of the matched text
     (or -1 for no match).

_S_e_e _A_l_s_o:

     'regexpr' for "simple" pattern matching.

_E_x_a_m_p_l_e_s:

     x <- c("\value{foo}", "function(bar)")
     delimMatch(x)
     delimMatch(x, c("(", ")"))

