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
| package main
import ( "fmt" "strings" )
func main() { a := "hello" fmt.Println(strings.Contains(a, "ll")) fmt.Println(strings.Count(a, "l")) fmt.Println(strings.HasPrefix(a, "he")) fmt.Println(strings.HasSuffix(a, "llo")) fmt.Println(strings.Index(a, "ll")) fmt.Println(strings.Join([]string{"he", "llo"}, "-")) fmt.Println(strings.Split("a-b-c", "-")) fmt.Println(strings.Repeat(a, 2)) fmt.Println(strings.Replace(a, "l", "L", 1)) fmt.Println(strings.Replace(a, "l", "L", 2)) fmt.Println(strings.Replace(a, "l", "L", 3)) fmt.Println(strings.Replace(a, "l", "L", -1)) fmt.Println(strings.ToLower(a)) fmt.Println(strings.ToUpper(a)) fmt.Println(len(a)) b := "你好" fmt.Println(len(b)) }
|