\Header{delimMatch}{Delimited Pattern Matching}
\keyword{character}{delimMatch}
\begin{Description}\relax
Match delimited substrings in a character vector, with proper nesting.
\end{Description}
\begin{Usage}
\begin{verbatim}
delimMatch(x, delim = c("{", "}"), syntax = "Rd")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a character vector.
\item[\code{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.
\item[\code{syntax}] currently, always the string \samp{"Rd"} indicating Rd
syntax (i.e., \samp{\%} starts a comment extending till the end of
the line, and \samp{\bsl{}} escapes).  Future versions might know about
other syntaxes, perhaps via \dQuote{syntax tables} allowing to
flexibly specify comment, escape, and quote characters.
\end{ldescription}
\end{Arguments}
\begin{Value}
An integer vector of the same length as \code{x} giving the starting
position of the first match, or \eqn{-1}{} if there is none, with
attribute \code{"match.length"} giving the length of the matched text
(or \eqn{-1}{} for no match).
\end{Value}
\begin{SeeAlso}\relax
\code{\Link{regexpr}} for \dQuote{simple} pattern matching.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- c("\value{foo}", "function(bar)")
delimMatch(x)
delimMatch(x, c("(", ")"))
\end{ExampleCode}
\end{Examples}

