0
可能是一個愚蠢的事情,但就死在它有點...如何修整「[」從Golang串字符
不能剪裁一個字符串的字符"["
,東西我試圖與輸出:
package main
import (
"fmt"
"strings"
)
func main() {
s := "this[things]I would like to remove"
t := strings.Trim(s, "[")
fmt.Printf("%s\n", t)
}
// output: this[things]I would like to remove
也試過所有這些,沒有成功:
s := "this [ things]I would like to remove"
t := strings.Trim(s, " [ ")
// output: this [ things]I would like to remove
s := "this [ things]I would like to remove"
t := strings.Trim(s, "[")
// output: this [ things]I would like to remove
沒有工作。我在這裏錯過了什麼?
https://golang.org/pkg/strings/#Replace –