Skip to contents

Prepare a pattern from a vector of characters. It particularly useful to find files of given extension within a vector of names.

Usage

complete_pattern(x, begin = FALSE, ending = FALSE, extension = FALSE)

Arguments

x

character, vector of patterns to be completed

begin

logical, should the pattern be at the beginning of strings

ending

logical, should the pattern be at the end of strings

extension

logical, should the pattern considered as an extension with a starting dot

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$"