package main
import (
"fmt"
"reflect"
"strings"
)
var p = fmt.Println
func main() {
src := "this is a string"
//是否包含ing,返回布尔值
p("Contains: ", strings.Contains(src, "ing"))
//计算i 出现的次数,返回次数
p("Count: ", strings.Count(src, "i"))
//字符串是否以dd开头,返回布尔值,HasSuffix 判断后缀
p("HasPrefix: ", strings.HasPrefix(src, "dd"))
//查找i在字符串中的下标,从左往右第一个,返回下标
p("Index: ", strings.Index(src, "i"))
//查找最后一次出现的位置,返回从左往右的下标
p("LastIndex ", strings.LastIndex(src, "i"))
//用-连接数组s
var s = []string{"aa", "bb", "cc"}
p("Join: ", strings.Join(s, "-"))
//将字符串重复两次,就是将src 乘2 合并成一个
p("Repeat: ", strings.Repeat(src, 2))
//大小写转换,小写:ToLower
p("ToUpper: ", strings.ToUpper(src))
//以指定的分隔符分割字符串//Split: []string [a c d e]
var a string = "a,c,d,e"
p("Split: ", reflect.TypeOf(strings.Split(a, ",")), strings.Split(a, ","))
}