I need to know if there are any functions available in R that allow me to check if one string contains a substring and return a boolean. I've already tried str_detect but that doesn't suit my need.
For example:
string = 12345REFUND4567
and
substring = REFUND
contains(string,substring) would ideally return TRUE
since 12345REFUND4567 contains REFUND.
contains(string,substring) is just the format I'd imagine the function to take.
You probably are looking for grepl:
string <- "12345REFUND4567"
grepl("REFUND", string, fixed=TRUE)
[1] TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With