Standard library / strings
strings.Split()
Splits around every literal separator. Empty separator splits after UTF-8 sequences. Expected stdout: '[a||b]\n'.
Formal Syntax & Structure
go syntaxgo
func Split(s, sep string) []stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| sep | string | Separator or search sequence. |
Return Value
[]string
Splits around every literal separator. Empty separator splits after UTF-8 sequences.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { v := strings.Split("a,,b", ",") fmt.Print("[") for i, x := range v { if i > 0 { fmt.Print("|") } fmt.Print(string(x)) } fmt.Println("]")}