find_pattern_in {hutils} | R Documentation |
Find string pattern in (text) file
Description
goto_pattern_in
present from 1.6.0
Usage
find_pattern_in(
file_contents,
basedir = ".",
dir_recursive = TRUE,
reader = readLines,
include.comments = FALSE,
comment.char = NULL,
use.OS = FALSE,
file_pattern = "\\.(R|r)(nw|md)?$",
file_contents_perl = TRUE,
file_contents_fixed = FALSE,
file_contents_ignore_case = FALSE,
file.ext = NULL,
which_lines = c("first", "all")
)
goto_pattern_in(file_contents, ...)
Arguments
file_contents |
A perl-regular expression as a search query. |
basedir |
The root of the directory tree in which files will be searched recursively. |
dir_recursive |
(logical, default: |
reader |
A function, akin to |
include.comments |
If |
comment.char |
If |
use.OS |
Use the operating system to determine file list. Only available on Windows. If it fails, a fall-back option
(using |
file_pattern |
A regular expression passed to |
file_contents_perl |
(logical, default: |
file_contents_fixed |
(logical, default: |
file_contents_ignore_case |
(logical, default: |
file.ext |
A file extension passed to the operating system if |
which_lines |
One of |
... |
Arguments passed to |
Details
For convenience, if file_contents
appears to be a directory
and basedir
does not, the arguments are swapped, but with a warning.
Value
A data.table
, showing the matches per file.
goto_pattern_in
additionally prompts for a row of the returned results.
Using the rstudioapi
, if available, RStudio will jump to the file
and line number.