| txtFindReplace | R Documentation |
This function reads a text file and replaces specified patterns with given replacements. It allows for multiple patterns and replacements, and can perform case-sensitive or case-insensitive searches. It can also match whole words.
txtFindReplace(
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, the function only lists the files that would be modified without actually modifying them. Defaults to FALSE. |
Returns list: name of file assessed = number of changes. The function modifies the text file in-place and prints the exact number of changes made.
fileFindReplace, xlsxFindReplace
## Not run:
txtFindReplace("example.txt", "oldText", "newText")
txtFindReplace("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.