\Header{substr}{Extract Substrings from a Character Vector}
\alias{substring}{substr}
\keyword{character}{substr}
\begin{Usage}
\begin{verbatim}
substr(x, start, stop)
substring(text, first, last = 1000000)
\end{verbatim}
\end{Usage}
\begin{Description}
Extract substrings from a character vector returning a
vector whose elements contain the substring starting with the
character at position \texttt{start} up to the character at position
\texttt{stop}.\end{Description}
\begin{Details}
If \texttt{start} is larger than the string length then
\texttt{\Link{NA}} is returned.
If \texttt{stop} is longer than \texttt{start} an error is signalled.

\texttt{substring} is compatible with S, with \texttt{first} and
\texttt{last} instead of \texttt{start} and \texttt{stop}.
For vector arguments, it expands the arguments cyclically.\end{Details}
\begin{SeeAlso}
\texttt{\Link{strsplit}}, \texttt{\Link{paste}}, \texttt{\Link{nchar}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
substr("abcdef",2,4)
print(ss <- substring("abcdef",1:6,1:6))
all(  ss == strsplit ("abcdef",NULL)[[1]])# strsplit is more efficient..

substr(rep("abcdef",4),1:4,4:5)
x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
all(substr(x, 2, 5) == substring(x, 2, 5)) #> TRUE
substr(x, 2, 5)
substring(x, 2, 4:6)
\end{ExampleCode}
\end{Examples}

