I didn't notice this while posting, and now can't figure out a better solution. I deleted my earlier post because of this issue.
If modifying the patterns is alright with your use case, then it should be OK. Instead of adding .* both before and after each pattern, you can use paste0 inside the function call as follows:
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(stringi)
df_patterns <- tibble(match_string = c(".*site1.com", ".*site2.com", ".*site3.com"),
site = c("villas", "brands", "club"))
saint <- tibble(Key = c("site1.com", "a.site1.com", "site2.com", "site2.com/b", "site3.com"))
saint %>%
mutate(Site = stri_replace_all_regex(str = Key,
pattern = paste0(".*", df_patterns$match_string, ".*"),
replacement = df_patterns$site,
vectorize_all = FALSE))
#> # A tibble: 5 x 2
#> Key Site
#> <chr> <chr>
#> 1 site1.com villas
#> 2 a.site1.com villas
#> 3 site2.com brands
#> 4 site2.com/b brands
#> 5 site3.com club