Strings Fields Golang

[Solved] Strings Fields Golang | Go - Code Explorer | yomemimo.com
Question : strings fields golang

Answered by : ben-mulongo

// Golang program to illustrate the
// strings.Fields() Function
package main
  
import (
    "fmt"
    "strings"
)
  
func main() {
  
    // Fields function also splits the string
    // on the basis of white spaces and tabs
    s := strings.Fields(" I \t love \n to \n code \n all \t day.")
    fmt.Println(s)
  
    // Splits into 5 words which have
    // newline character in between
    s = strings.Fields("I\nam\nlearning\nGo\nlanguage")
    fmt.Println(s)
}

Source : https://www.geeksforgeeks.org/strings-fields-function-in-golang-with-examples/ | Last Update : Mon, 06 Jun 22

Answers related to strings fields golang

Code Explorer Popular Question For Go