开发者

Regex question in C#

开发者 https://www.devze.com 2022-12-26 16:26 出处:网络
how to remove only one char (\") if there two(\"\") from the string in C# (Regex ) ex.: 123\"43\"\"343\"54\"\" ==>123\"43\"343\"54\"

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"开发者_JS百科"i  ==>  "abc"def"gh"i

thank's in advance


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


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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号