【问题标题】:Remove escape character "\" from string从字符串中删除转义字符“\”
【发布时间】:2014-04-26 13:38:44
【问题描述】:

我需要从imagepth 字符串变量中删除\ 字符:

imagepth = "# Eval(\"Name\",\"Gallary/\"" + imgwords[4] + "\"/Images/{0}\")";

【问题讨论】:

  • 我不确定我是否理解。据我所知, imagepth 在赋值之后不会包含一个反斜杠。

标签: c# asp.net .net escaping


【解决方案1】:

您可以使用 Replace 方法将"\\" 替换为空字符串

   str = str.Replace("\\", "");

【讨论】:

    【解决方案2】:

    Regex Unescape 将从字符串中删除所有转义字符,这里是该信息的链接:

    http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.unescape.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      相关资源
      最近更新 更多