diff options
author | Cameron Moore <moorereason@gmail.com> | 2020-09-07 15:29:55 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-09-07 22:45:14 +0200 |
commit | f7c1b5fe1c22ba5f16e3fa442df6a8a70711f23f (patch) | |
tree | a6bc257ef0bce05f434b1954b719fc9e46e5f2ea | |
parent | 183e8626070a5f55c11648082e3060e35231d934 (diff) |
docs: Update replaceRE func
Updates for #7604
-rw-r--r-- | docs/content/en/functions/replacere.md | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/docs/content/en/functions/replacere.md b/docs/content/en/functions/replacere.md index 9c2778b5f..f131169be 100644 --- a/docs/content/en/functions/replacere.md +++ b/docs/content/en/functions/replacere.md @@ -1,17 +1,16 @@ --- title: replaceRE -# linktitle: replaceRE description: Replaces all occurrences of a regular expression with the replacement pattern. godocref: date: 2017-02-01 publishdate: 2017-02-01 -lastmod: 2017-04-30 +lastmod: 2020-09-07 categories: [functions] menu: docs: parent: "functions" keywords: [regex] -signature: ["replaceRE PATTERN REPLACEMENT INPUT"] +signature: ["strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]", "replaceRE PATTERN REPLACEMENT INPUT [LIMIT]"] workson: [] hugoversion: relatedfuncs: [] @@ -19,9 +18,14 @@ deprecated: false aliases: [] --- +`strings.ReplaceRE` returns a copy of `INPUT`, replacing all matches of the regular +expression `PATTERN` with the replacement text `REPLACEMENT`. +The number of replacements can be limited with an optional `LIMIT` parameter. + ``` {{ replaceRE "^https?://([^/]+).*" "$1" "http://gohugo.io/docs" }}` → "gohugo.io" {{ "http://gohugo.io/docs" | replaceRE "^https?://([^/]+).*" "$1" }}` → "gohugo.io" +{{ replaceRE "a+b" "X" "aabbaabbab" 1 }} → "Xbaabbab" ``` {{% note %}} |