Gold
Gold

Reputation: 62554

Regex question in C#

how to remove only one char (") if there two("") from the string in C# (Regex )

ex.:

123"43""343"54"" ==>  123"43"343"54"

"abc""def"gh""i  ==>  "abc"def"gh"i

thank's in advance

Upvotes: 1

Views: 80

Answers (3)

Andrew
Andrew

Reputation: 1102

Regex regExp = new Regex("\"\"");
string test = "123\"\"123\"\"123";
string tempTxt = regExp.Replace(test, "\"");

Something like this? But yeah, i think Regex isn't good choise here.

Upvotes: 0

Anthony Pegram
Anthony Pegram

Reputation: 126952

someString.Replace(@"""""",@""""); should work, shouldn't it?

while (someString.IndexOf(@"""""") > -1)
{
   someString = someString.Replace(@"""""",@"""");
}

Upvotes: 2

codaddict
codaddict

Reputation: 455380

You don't need regex for this. Just search for the sub-string "" and replace it with "

Upvotes: 4

Related Questions