1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| s := "A good tree bears good fruit" fmt.Printf("%t\n", strings.Contains(s, "tree")) >>>>>> true
fmt.Println(strings.Index("Hi I'm Nick, Hi", "Nick")) fmt.Println(strings.Index("Hi I'm Nick, Hi", "Hi")) fmt.Println(strings.Index("Hi I'm Nick, Hi", "abc")) fmt.Println(strings.LastIndex("Hi I'm Nick, Hi", "Hi"))
fmt.Println(strings.Replace("你好世界", "世界", "地球", 1)) >>>>>> 你好地球
s := "A good tree bears good fruit" s1 := "HOW ARE YOU?" fmt.Printf("%s\n", strings.ToUpper(s)) fmt.Printf("%s\n", strings.ToLower(s1)) >>>>>> A GOOD TREE BEARS GOOD FRUIT how are you?
fmt.Printf("%q\n", strings.Trim(" Golang ", " ")) fmt.Printf("%q\n", strings.TrimLeft(" Golang ", " ")) fmt.Printf("%q\n", strings.TrimRight(" Golang ", " ")) >>>>>> "Golang" "Golang " " Golang"
fmt.Printf("%q\n", strings.Split("a,b,c", ",")) fmt.Printf("%q\n", strings.Split("a boy a girl a cat", "a ")) fmt.Printf("%q\n", strings.Split("xyz", "")) >>>>>> ["a" "b" "c"] ["" "boy " "girl " "cat"] ["x" "y" "z"]
fmt.Printf("%q\n", strings.Join([]string{"boy", "girl", "cat"}, ";")) >>>>>> "boy;girl;cat"
|