Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove the escape characters from this string?

Tags:

c#

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.

like image 926
WhiskerBiscuit Avatar asked Dec 12 '22 07:12

WhiskerBiscuit


1 Answers

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

like image 118
SeeMoreGain Avatar answered Dec 28 '22 06:12

SeeMoreGain