See template gsub("[\\]]","==","hello\\] [world]"), [\]]effectively matches \and then ]. Try gsub("[\\]]","==","hello\\] [world]")it and the result will be hello== [world], a literal backslash will be replaced.
In the regular expression pattern, TRE a \inside the parenthesis expression matches a literal backslash.
"[\\]]" \ :
gsub("[[]","==","hello [world]")
- R.
PCRE, , PCRE :
gsub("[\\[]","==","hello [world]", perl=TRUE)
[, ], ][ :
gsub("[][]","==","hello [world]")