0

I realise there's another similar question asked 3 years ago at Are there raw strings in R for regular expressions?, but wonder if there is now a new answer to the question.

So, my question is more general about writing raw strings, not just for regex but also for windows paths and other strings that can have backlash present.

paolov
  • 2,139
  • 1
  • 34
  • 43

1 Answers1

3

With R>4.0.0, you can parse raw strings using the following syntax:

> r"(C:\Users\)"
[1] C:\\Users\\

Note that, () are part of syntax i.e. r"(....)". You can use r"{...}" and r"[....]" also. Also note that, the double back slashes which you see printed is R's way of printing backslashes.

monte
  • 1,482
  • 1
  • 10
  • 26