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
  • 36,059
  • 54
  • 198
  • 383
Amanda_Panda
  • 1,081
  • 3
  • 24
  • 65

1 Answers1

10

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

withoutQuotes = withQuotes.Replace("\"", "");
Jon Skeet
  • 1,335,956
  • 823
  • 8,931
  • 9,049