fileFindReplace | R Documentation |
This function reads a file and replaces specified patterns with given replacements. The function can work with multiple patterns and replacements, and can also perform case-sensitive or case-insensitive searches.
fileFindReplace(
filename,
pattern,
replacement,
word = TRUE,
ignore.case = FALSE,
listonly = FALSE
)
filename |
Character. The name of the file to modify. |
pattern |
Character vector. A vector of patterns to search for in the file. |
replacement |
Character vector. A vector of replacements for the patterns found. |
word |
Logical. If TRUE, only whole words will be replaced. Defaults to TRUE. |
ignore.case |
Logical. If TRUE, the function performs a case-insensitive search. Defaults to FALSE. |
listonly |
Logical. If TRUE, instead of modifying the files, a summary of the changes that would be made is displayed.. This is used to check changes before applying them. Defaults to FALSE. |
Returns list: name of file assessed = number of changes. The function modifies the file in-place.
txtFindReplace
, xlsxFindReplace
## Not run:
fileFindReplace("example.txt", "oldText", "newText")
fileFindReplace("example.txt", c("oldText1", "oldText2"), "newText")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.