powered by
SQL
LIKE
str_like() follows the conventions of the SQL LIKE operator:
str_like()
Must match the entire string.
_ matches a single character (like .).
_
.
% matches any number of characters (like .*).
%
.*
\% and \_ match literal % and _.
\%
\_
The match is case insensitive by default.
str_like(string, pattern, ignore_case = TRUE)
A logical vector the same length as string.
string
Input vector. Either a character vector, or something coercible to one.
A character vector containing a SQL "like" pattern. See above for details.
Ignore case of matches? Defaults to TRUE to match the SQL LIKE operator.
TRUE
fruit <- c("apple", "banana", "pear", "pineapple") str_like(fruit, "app") str_like(fruit, "app%") str_like(fruit, "ba_ana") str_like(fruit, "%APPLE")
Run the code above in your browser using DataLab