可能是一件小事情,但我却卡在这上面了一会儿...
无法从字符串中删除 "["
字符,以下是我尝试过的方法及输出结果:
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
没有一个有效。我在这里漏掉了什么?