strings.TrimPrefix.md (717B)
1 ---
2 title: strings.TrimPrefix
3 description: Returns a given string s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
4 date: 2017-02-01
5 publishdate: 2017-02-01
6 lastmod: 2017-02-01
7 categories: [functions]
8 menu:
9 docs:
10 parent: "functions"
11 keywords: [strings]
12 signature: ["strings.TrimPrefix PREFIX STRING"]
13 workson: []
14 hugoversion:
15 relatedfuncs: [strings.TrimSuffix]
16 deprecated: false
17 aliases: []
18 ---
19
20 Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it:
21
22 {{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa"
23 {{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa"
24 {{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa"