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("(", ")"))

