aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/content/en/functions/strings.TrimPrefix.md
blob: c3f7029610ab5c8598d1b4f2e3a2ddcc5827cdcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
title: strings.TrimPrefix
description: Returns a given string s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
categories: [functions]
menu:
  docs:
    parent: functions
keywords: [strings]
signature: ["strings.TrimPrefix PREFIX STRING"]
relatedfuncs: [strings.TrimSuffix]
---

Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it:

    {{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa"
    {{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa"
    {{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa"