Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Split

  • Split
package main

import (
	"fmt"
	"strings"
)

func main() {
	text := "This text,has,comma separated,vales"
	fmt.Println(text)

	shortStrings := strings.Split(text, ",")
	fmt.Println(shortStrings)
	fmt.Println(len(shortStrings))

	veryShortStrings := strings.Split(text, "")
	fmt.Println(veryShortStrings)
	fmt.Println(len(veryShortStrings))
}
This text,has,comma separated,vales
[This text has comma separated vales]
4
[T h i s   t e x t , h a s , c o m m a   s e p a r a t e d , v a l e s]
35