5

I have a string called argument that I need to send to a process. My argument was built and when I check the value from the immediate window I get this:

argument
" -i \"M:\\visual studio 2013\\cherry\\Database\\script.sql\" -v varDb=foobar"

what I want is to have this: (replace \ with \ and replace \" with ")

argument
" -i "M:\visual studio 2013\cherry\Database\script.sql" -v varDb=foobar"

I'm somewhat embarrassed I have to ask this, but I've tried all sorts of .Replace and regex expressions already.

WhiskerBiscuit
  • 4,795
  • 8
  • 62
  • 100
  • 1
    You already have what you want. The immediate window doesn't interpret escape characters. – Ant P Mar 10 '14 at 00:03
  • Duplicate of (with better answers): http://stackoverflow.com/questions/2327540/copy-value-of-watch-variable-in-visual-studio-without-escape-characters – Don Cheadle May 03 '16 at 21:04

2 Answers2

8

As has been mentioned by others, the immediate window shows the unescaped string (by default). This can be changed using format specifiers (MSDN). Appending ,nq should remove escape chars

See: Copy value of watch variable in visual studio without escape characters for an example

Community
  • 1
  • 1
SeeMoreGain
  • 1,263
  • 16
  • 36
7

The immediate window is showing it to you escaped because that's how it displays a string. You don't have any escape characters in the actual string.

You can't manage to remove them cause they're not actually there. It's a display feature of the immediate window.

I suspect the real issue must be elsewhere in your code.

fyjham
  • 7,004
  • 2
  • 32
  • 40