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