本文共 368 字,大约阅读时间需要 1 分钟。
package mainimport ( "fmt" "strings")func main() { fmt.Println("Hello World!") a := "golang strings.Split获取字符串中的url/域名的简易方法http://www.waylau.com/golang-strings-split-get-url/" a1 := strings.Split(a, "//")[1] a2 := strings.Split(a1, "/")[0] fmt.Println(a1) //输出为:www.waylau.com/golang-strings-split-get-url/ fmt.Println(a2) //输出为:www.waylau.com}
转载地址:http://iapvo.baihongyu.com/