0

I'm trying to find and replace all instances of a double quote in a C# string using regex, but can't quite seem to grasp the answer, here is what I have so far:

private string checkEscapeChars(string s)
{
    s = Regex.Replace(s, @"[""]", String.Empty);
    return s;
}

Now, that runs okay, but lets say I have a string "this is my "Sample string"

I want to get rid of the " before Sample. Will the above work for that? Or will it find and replace all instances of matching double quotes, rather than single double quotes?

Dave New
  • 38,496
  • 59
  • 215
  • 394
Amanda_Panda
  • 1,156
  • 4
  • 26
  • 68

1 Answers1

10

Why would you want to use a regular expression for this? Just use String.Replace:

withoutQuotes = withQuotes.Replace("\"", "");
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194