diff --git a/NEWS.md b/NEWS.md index 697c7c71..95a8811b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # stringr (development version) +* `str_like()` and `str_ilike()` now match regular expression metacharacters such as `.` and `*` literally (@taekop, #617). + # stringr 1.6.0 ## Breaking changes diff --git a/R/detect.R b/R/detect.R index 1c258df0..de525974 100644 --- a/R/detect.R +++ b/R/detect.R @@ -241,11 +241,29 @@ str_ilike <- function(string, pattern) { } like_to_regex <- function(pattern) { + converted <- escape_like_metachars(pattern) converted <- stri_replace_all_regex( - pattern, + converted, "(?