2

How can I include the escape character \ in a string, followed by *?

My incorrect string assignment: commandLine.rmTags = 'tag --remove \* test_file.png'

results in: Error: '\*' is an unrecognized escape in character string starting "'tag --remove \*"

Ultimately, the reason I need to do this is to call system() from R, for which the argument is the string above. I will be using it like this:

commandLine.rmTags = 'tag --remove \* test_file.png'
system(commandLine.rmTags)

Note: if you are curious, I am using jdberry's very cool Tag Terminal application.

tsouchlarakis
  • 1,499
  • 3
  • 23
  • 44
  • 2
    You need to escape the slash with another slash. So use `"\\*"` – MrFlick Mar 28 '17 at 01:59
  • 1
    This link might help - http://stackoverflow.com/questions/11806501/how-to-escape-backslashes-in-r-string – paul-shuvo Mar 28 '17 at 02:01
  • Thank you very much, both comments were helpful! I did not know that even though the string appeared as having two backslashes then, when I use `cat()` it shows the one backslash. – tsouchlarakis Mar 28 '17 at 03:07

0 Answers0