I'm not sure why I can't get a simple back reference to work in R/RStudio.
grepl('name\1','namename')
returns FALSE. grepl('(name)\1','namename')
is no good either.
What am I doing wrong?
Thanks!
Use the double backlash before 1
(the regex engine will understand it as a single backslash):
grepl('(name)\\1', 'namename')
## [1] TRUE
This is because:
cat('(name)\\1')
## (name)\1
In your case, \1 == \001
means an ASCII character of code 1.
charToRaw('\1')
## [1] 01
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