delimMatch {tools} | R Documentation |
Match delimited substrings in a character vector, with proper nesting.
delimMatch(x, delim = c("{", "}"), syntax = "Rd")
x |
a character vector. |
delim |
a character vector of length 2 giving the start and end delimiters. 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. |
An integer vector of the same length as x
giving the starting
position (in characters) of the first match, or -1 if there is
none, with attribute "match.length"
giving the length (in
characters) of the matched text (or -1 for no match).
regexpr
for “simple” pattern matching.
x <- c("\value{foo}", "function(bar)") delimMatch(x) delimMatch(x, c("(", ")"))