strings.Split in Go

前端 未结 2 1869
南方客
南方客 2021-02-19 23:14

The file names.txt consists of many names in the form of:

\"KELLEE\",\"JOSLYN\",\"JASON\",\"INGER\",\"INDIRA\",\"GLINDA\",\"GLENNIS\"

Does anyo

2条回答
  •  你的背包
    2021-02-20 00:03

    Split doesn't remove characters from the substrings. Your split is fine you just need to process the slice afterwards with strings.Trim(val, "\"").

    for i, val := range arr {
      arr[i] = strings.Trim(val, "\"")
    }
    

    Now arr will have the leading and trailing "s removed.

提交回复
热议问题