dongyigua4468
2017-05-27 23:46
浏览 1.2k
已采纳

如何在Golang中删除字符串周围的引号

I have a string in Golang that is surrounded by quote marks. My goal is to remove all quote marks on the sides, but to ignore all quote marks in the interior of the string. How should I go about doing this? My instinct tells me to use a RemoveAt function like in C#, but I don't see anything like that in Go.

For instance:

"hello""world"

should be converted to:

hello""world

For further clarification, this:

"""hello"""

would become this:

""hello""

because the outer ones should be removed ONLY.

图片转代码服务由CSDN问答提供 功能建议

我在Golang中有一个用引号引起来的字符串。 我的目标是删除侧面的所有引号,但忽略字符串内部的所有引号。 我应该怎么做呢? 我的直觉告诉我像在C#中那样使用RemoveAt函数,但在Go中看不到类似的东西。

例如:

  “ hello”“ world” 
   
 
 

应转换为:

  hello“” world \  n   
 
 

为进一步说明,

 “”“” hello“”“ 
  <  / pre> 
 
 

会变成这样:

 “” hello“” 
   
 
 

因为外面的东西只能去除。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题