Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

strrep

Find and replace substring


Description

Find and replace all occurrences of a substring with another one in all strings of a character vector.

Usage

strRep(s, old, new)

Arguments

s

Character vector.

old

String to be replaced.

new

String that replaces another one.

Details

Replaces all occurrences of old with new in all strings of character vector s. The matching is case sensitive.

Value

A character vector of the same length.

See Also

gsub, regexprep

Examples

S <- c('This is a good example.', "He has a good character.",
       'This is good, good food.', "How goodgood this is!")
strRep(S, 'good', 'great')

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.