Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'

This commit is contained in:
Bjørn Erik Pedersen
2023-05-22 16:47:07 +02:00
341 changed files with 3107 additions and 4238 deletions

View File

@@ -1,23 +1,15 @@
---
title: substr
# linktitle:
description: Extracts parts of a string from a specified character's position and returns the specified number of characters.
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
menu:
docs:
parent: "functions"
parent: functions
keywords: [strings]
aliases: []
signature:
- "substr STRING START [LENGTH]"
- "strings.Substr STRING START [LENGTH]"
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
---
It normally takes two parameters: `start` and `length`. It can also take one parameter: `start`, i.e. `length` is omitted, in which case the substring starting from start until the end of the string will be returned.
@@ -26,7 +18,7 @@ To extract characters from the end of the string, use a negative start number.
If `length` is given and is negative, that number of characters will be omitted from the end of string.
```
```go-html-template
{{ substr "abcdef" 0 }} → "abcdef"
{{ substr "abcdef" 1 }} → "bcdef"