652cee0e2e
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
564 B
564 B
layout, title, summary, date, tags
| layout | title | summary | date | tags |
|---|---|---|---|---|
| post.html | T.I.L. Split on spaces in Go | Today I Learnt: Split on spaces in Go | 2020-09-18 | til go golang |
While looking to split a multiline and space separated string and not having any luck with strings.Split() I came across this somewhat oddly names function:
import (
"fmt"
"strings"
)
func main() {
input := `This is
a multiline, space
separated string`
output := strings.Fields(input)
fmt.Println(output) // ["This", "is", "a", "multiline,", "space", "separated", "string"]
}