Filter with str_detect

tidyverse
code
Author

Ravi C

Published

January 25, 2023

To filter using str_detect, generally you can use the code as follows:

stringr::str_detect("ravi chowdhury", "ravi")
[1] TRUE

as we can see the it returns logical TRUE which means it was able to find the string, however str_detect is case sensitive as seen below:

stringr::str_detect("Ravi Chowdhury", "ravi")
[1] FALSE

To fix this we can use regex function ignore_case

stringr::str_detect("Ravi Chowdhury", regex("ravi", ignore_case = TRUE))
[1] TRUE