% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/locbalpar.R
\name{locbalpar}
\alias{locbalpar}
\title{Return the locations of the matching parentheses in a string.}
\usage{
locbalpar(exp, loc)
}
\arguments{
\item{exp}{Input string: a single (vector of length 1).}

\item{loc}{The starting or ending locations of the parentheses
whose matching pair will be found.}
}
\value{
The location vecotr of length(loc) of the matching parens  or  0.
}
\description{
Return the locations of the matching parentheses in a string.
}
\details{
\code{loc} must be positive and less than \code{nchar(exp)}.\cr
\code{substring(exp,loc,loc)} must be opening or closing parens.\cr
Otherwise, this function returns 0.
}
\examples{
# Input string
#                1111111111222222222233333333
#       1234567890123456789012345678901234567
exp <- "a+([a+b]*(c*{d+e}))-(f-g) +(((<()>)) "

locbalpar( exp, 3 )
locbalpar( exp, 19 )
locbalpar( exp, c(4,8) )
locbalpar( exp, c(13,17) )
locbalpar( exp, c(31,34) )
locbalpar( exp, c(34,31, 3,19) )

locbalpar( exp, regexpr( "\\\\(", exp ) )

# No matching paren
locbalpar( exp, 28 )


# As long as substr(exp,n,1) is a paren, below should always be true.
n <- 10; n == locbalpar( exp, locbalpar( exp, n ) )
n <- 36; n == locbalpar( exp, locbalpar( exp, n ) )

}
