1---
2title: trim
3# linktitle:
4description: Returns a slice of a passed string with all leading and trailing characters from cutset removed.
5date: 2017-02-01
6publishdate: 2017-02-01
7lastmod: 2017-02-01
8categories: [functions]
9menu:
10  docs:
11    parent: "functions"
12keywords: [strings]
13signature: ["trim INPUT CUTSET"]
14workson: []
15hugoversion:
16relatedfuncs: []
17deprecated: false
18---
19
20```
21{{ trim "++Batman--" "+-" }} → "Batman"
22```
23
24`trim` *requires* the second argument, which tells the function specifically what to remove from the first argument. There is no default value for the second argument, so **the following usage will not work**:
25
26```
27{{ trim .Inner}}
28```
29
30Instead, the following example tells `trim` to remove extra new lines from the content contained in the [shortcode `.Inner` variable][shortcodevars]:
31
32```
33{{ trim .Inner "\n" }}
34```
35
36{{% note %}}
37Go templates also provide a simple [method for trimming whitespace](/templates/introduction/#whitespace) from either side of a Go tag by including a hyphen (`-`).
38{{% /note %}}
39
40
41[shortcodevars]: /variables/shortcodes/
42