Go strings Package Split()

Introduction

To split a string into a list of strings by a separating string (e.g., a comma), use the Split function.

Split() is the reverse of Join().


package main //from w  w  w  .  ja va2  s. co m

import ( 
    "fmt" 
    "strings" 
) 

func main() { 
    // func Split(s, sep string) []string 
    fmt.Println(strings.Split("a-b-c-d-e", "-"))
    // => []string{"a","b","c","d","e"} 
} 



PreviousNext

Related