
Prepare a pattern for grep
complete_pattern.Rd
Prepare a pattern from a vector of characters. It particularly useful to find files of given extension within a vector of names.
Value
character of length one. To each element of x, it is firts applied transformation given by begin, ending and extention. Then, it is collapsed with "|". It can be used in a grep call.
Examples
extension = c("zip", "7z")
complete_pattern(extension)
#> [1] "zip|7z"
complete_pattern(extension, extension = TRUE)
#> [1] "[.]zip|[.]7z"
complete_pattern(extension, ending = TRUE)
#> [1] "zip$|7z$"