mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
29 lines
798 B
Markdown
29 lines
798 B
Markdown
---
|
|
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]
|
|
keywords: []
|
|
menu:
|
|
docs:
|
|
parent: functions
|
|
function:
|
|
aliases: []
|
|
returnType: string
|
|
signatures: [strings.TrimPrefix PREFIX STRING]
|
|
relatedFunctions:
|
|
- strings.Chomp
|
|
- strings.Trim
|
|
- strings.TrimLeft
|
|
- strings.TrimPrefix
|
|
- strings.TrimRight
|
|
- strings.TrimSuffix
|
|
aliases: [/functions/strings.trimprefix]
|
|
---
|
|
|
|
Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it:
|
|
|
|
```go-html-template
|
|
{{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa"
|
|
{{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa"
|
|
{{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa"
|
|
```
|