% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/replacec.R
\name{replacec}
\alias{replacec}
\title{Replace Characters by New Ones}
\usage{
replacec(from, to, char, n = 1, start = 1, fixed = 1, ...)
}
\arguments{
\item{from}{A character string to be replaced by "to".
By default, there are no need to escape special characters.}

\item{to}{A character string to replace "from".}

\item{char}{A character vector where replacement occur.}

\item{n}{# of times to replace}

\item{start}{The location from which the replacement starts.}

\item{fixed}{A parameter to be passed to gregexpr and gsub.}

\item{...}{Additional parameters to gregexpr and gsub.}
}
\value{
A string with replacement.
}
\description{
Replace Characters by New Ones
}
\details{
Do not use regular expressions in from such as [a-b] etc. \cr
When from does not contain regular expression, \cr
fixed=0 and ignoe.case=1 \cr
should work.
}
\examples{
char <- paste( paste(letters,collapse=""),"0123456789",'"'
          , "'`!#$\%&'()[]{}<>*+-,.;:/^~=_|", sep="", collapse="" )
lchar <- nchar(char)
char <- paste(char,char,char,sep=" ",collapse="")


# one to one
replacec( "b", "B", char )
replacec( "b", "B", char, 2 )
replacec( "b", "B", char, 1, 135)

# many to one
replacec( "bc", "B", char )
replacec( "bc", "B", char, 2 )
replacec( "bc", "B", char, 1, 135 )

# one to many
replacec( "b", "BC", char )
replacec( "b", "BC", char, 2 )
replacec( "b", "BC", char, 1, 135 )

# to null string
replacec( "b", "", char, 99 )

# special characters
replacec( "(", "[paren]", char )
replacec( "^", "[hat]", char )
replacec( "!#$", "[esd]", char )

# ignore.case
replacec("B","[B]",char, fixed=0, ignore.case=1 )

}
