| 1 |
--- |
| 2 |
title: strings.Split |
| 3 |
description: Returns a slice of strings by splitting the given string by a delimiter. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [split] |
| 9 |
returnType: '[]string' |
| 10 |
signatures: [strings.Split STRING DELIM] |
| 11 |
aliases: [/functions/split] |
| 12 |
--- |
| 13 |
|
| 14 |
Examples: |
| 15 |
|
| 16 |
```go-html-template |
| 17 |
{{ split "tag1,tag2,tag3" "," }} → ["tag1", "tag2", "tag3"] |
| 18 |
{{ split "abc" "" }} → ["a", "b", "c"] |
| 19 |
``` |
| 20 |
|
| 21 |
> [!NOTE] |
| 22 |
> The `strings.Split` function essentially does the opposite of the [`collections.Delimit`][] function. While `split` creates a slice from a string, `delimit` creates a string from a slice. |
| 23 |
|
| 24 |
[`collections.Delimit`]: /functions/collections/delimit/ |