In R I have a string like
file = "c:\\hello\\nihao"
How do I replace all the \ with /? The ?gsub documentation is really confusing! You should get extra points for pointing to a good R regex resource!!
Why not just use the fixed = TRUE
argument?
gsub("\\", "/", file, fixed=TRUE)
# [1] "c:/hello/nihao"
Alternatively:
gsub("\\\\", "/", file)
# [1] "c:/hello/nihao"
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