I have a problem with grep in R:
patterns= c("AB_(1)","AB_(2)") text= c("AB_(1)","DDD","CC") grep(patterns[1],text) >integer(0) ????
the grep command has problem with "()" brackets, is there any as.XX(patterns[1]) that I can use??
You need escape by double backslash:
> patterns= c("AB_\\(1\\)","AB_(2)") > text= c("AB_(1)","DDD","CC") > > grep(patterns[1],text) [1] 1
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