mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,18 +3,15 @@ title: strings.ReplaceRE
|
||||
description: Returns a copy of INPUT, replacing all occurrences of a regular expression with a replacement pattern.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [replaceRE]
|
||||
related:
|
||||
- functions/strings/FindRE
|
||||
- functions/strings/FindRESubmatch
|
||||
- functions/strings/Replace
|
||||
returnType: string
|
||||
signatures: ['strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [replaceRE]
|
||||
returnType: string
|
||||
signatures: ['strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]']
|
||||
aliases: [/functions/replacere]
|
||||
---
|
||||
|
||||
{{% include "functions/_common/regular-expressions.md" %}}
|
||||
{{% include "/_common/functions/regular-expressions.md" %}}
|
||||
|
||||
```go-html-template
|
||||
{{ $s := "a-b--c---d" }}
|
||||
@@ -35,9 +32,7 @@ Use `$1`, `$2`, etc. within the replacement string to insert the content of each
|
||||
{{ replaceRE "^https?://([^/]+).*" "$1" $s }} → gohugo.io
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> You can write and test your regular expression using [regex101.com]. Be sure to select the Go flavor before you begin.
|
||||
|
||||
[RE2]: https://github.com/google/re2/wiki/Syntax
|
||||
[string literal]: https://go.dev/ref/spec#String_literals
|
||||
[regex101.com]: https://regex101.com/
|
||||
|
Reference in New Issue
Block a user