Replace string pattern in text file
replace_pattern_in(file_contents, replace, basedir = ".",
dir_recursive = TRUE, reader = readLines,
file_pattern = "\\.(R|r)(nw|md)?$", file_contents_perl = TRUE,
file_contents_fixed = FALSE, file_contents_ignore_case = FALSE,
writer = writeLines)Character string containing a regular expression to be matched in the
given character vector. Passed to pattern in gsub.
The replacement, passed to replacement in gsub.
The root of the directory tree in which files will be searched recursively.
(logical, default: TRUE) Search within subdirectories of basedir?
A function, akin to base::readLines, the default, that accepts a filename and returns a character vector.
A regular expression passed to list.files(pattern = file.ext).
By default, "\.(R|r)(nw|md)?$", i.e. all R and Sweave files. (Does not have to be a file extension.)
(logical, default: TRUE) Should file_contents
be interpreted as a perl regex?
(logical, default: FALSE) Should file_contents
be interpreted as a fixed regex?
(logical, default: FALSE) As in grep.
A function that will rewrite the file from the character vector read in.