mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,19 +3,16 @@ title: strings.FindRE
|
||||
description: Returns a slice of strings that match the regular expression.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [findRE]
|
||||
related:
|
||||
- functions/strings/FindRESubmatch
|
||||
- functions/strings/Replace
|
||||
- functions/strings/ReplaceRE
|
||||
returnType: '[]string'
|
||||
signatures: ['strings.FindRE PATTERN INPUT [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [findRE]
|
||||
returnType: '[]string'
|
||||
signatures: ['strings.FindRE PATTERN INPUT [LIMIT]']
|
||||
aliases: [/functions/findre]
|
||||
---
|
||||
By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT argument.
|
||||
|
||||
{{% include "functions/_common/regular-expressions.md" %}}
|
||||
{{% include "/_common/functions/regular-expressions.md" %}}
|
||||
|
||||
This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`:
|
||||
|
||||
@@ -31,6 +28,5 @@ To limit the number of matches to one:
|
||||
{{ findRE `(?s)<h2.*?>.*?</h2>` .Content 1 }}
|
||||
```
|
||||
|
||||
{{% 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](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
|
Reference in New Issue
Block a user