扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
package main
import (
"fmt"
"strings"
)
func main() {
//判断父字符串是否包含子字符串,包含为真,否则为假
fmt.Println("-------------------------------")
fmt.Println("contains Function:", strings.Contains("Austrilia", "lia"))
fmt.Println("contains Function:", strings.Contains("Austrilia", "mia"))
//子字符串在父字符串中出现的次数
fmt.Println("-------------------------------")
fmt.Println("Count Function: ",strings.Count("Australia", "lia"))
fmt.Println("Count Function: ",strings.Count("Australia", "A"))
fmt.Println("Count Function: ",strings.Count("Australia", "Bu"))
//判断子字符串是否为父字符串的前缀
fmt.Println("-------------------------------")
fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Bu"))
fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Aus"))
////判断子字符串是否为父字符串的后缀
fmt.Println("-------------------------------")
fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "lia"))
fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "tia"))
//子字符串首次出现在父子符串的索引下标
fmt.Println("-------------------------------")
fmt.Println("Index Function:",strings.Index("Australia", "lia"))
fmt.Println("Index Function: ",strings.Index("Australia", "a"))
fmt.Println("Index Function: ",strings.Index("Australia", "A"))
//连接函数,指定分隔符将字符串连接起来
fmt.Println("-------------------------------")
fmt.Println("Join Functions:",strings.Join([]string{"Austrilia", "Japen", "Germany"}, "-"))
fmt.Println("Join Function: ",strings.Join([]string{"Australia","Japan","Germany"}," "))
//重复函数,指定字符串重复出现的次数
fmt.Println("-------------------------------")
fmt.Println("Repeat Function:", strings.Repeat("Australia",3))
//替换字符串函数,
fmt.Println("-------------------------------")
fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",1))
fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",2))
fmt.Println("Replace Function: ",strings.Replace("Aaustralia ","a","b",3))
fmt.Println("Replace Function: ",strings.Replace("Australia ","A","B",1))
fmt.Println("Replace Function: ",strings.Replace("Australia ","lia","pia",1))
//分割函数,指定分隔符分隔字符串
fmt.Println("-------------------------------")
fmt.Println("Split Function:", strings.Split("Australia-Japan-Germany","-"))
//把字符转小写
fmt.Println("-------------------------------")
fmt.Println("ToLower Function: ",strings.ToLower("Australia"))
//把字符串转大写
fmt.Println("-------------------------------")
fmt.Println("ToUpper Function: ",strings.ToUpper("Australia"))
}
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。
10多年的鄠邑网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整鄠邑建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“鄠邑网站设计”,“鄠邑网站推广”以来,每个客户项目都认真落实执行。我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流