问题
I need to ">" with "\". Example : "a>b" should be changed to "a\b"
I have tried gsub
> test <- "a>b"
> gsub(">","\\",test, fixed = TRUE)
[1] "a\\b"
I have tried StringR str_replace
> library(stringr)
> str_replace(test,">","\\")
[1] "ab"
I have tried Stringi str_replace_all_fixed
> library(stringi)
> stri_replace_all_fixed(test,">","\\")
[1] "a\\b"
How do I escape \ in replacement. I guess when you give \, it is expecting \1, \2 etc for captured groups. How to avoid this
来源:https://stackoverflow.com/questions/46239045/how-to-give-backslash-as-replacement-in-r-string-replace