github.com/rabbouni145/gg@v0.47.1/docs/content/en/functions/findRe.md (about) 1 --- 2 title: findRE 3 description: Returns a list of strings that match the regular expression. 4 godocref: 5 date: 2017-02-01 6 publishdate: 2017-02-01 7 lastmod: 2017-02-01 8 categories: [functions] 9 menu: 10 docs: 11 parent: "functions" 12 keywords: [regex] 13 signature: ["findRE PATTERN INPUT [LIMIT]"] 14 workson: [] 15 hugoversion: 16 relatedfuncs: [] 17 deprecated: false 18 aliases: [] 19 --- 20 21 22 By default all matches will be included. The number of matches can be limitted with an optional third parameter. 23 24 The example below returns a list of all second level headers (`<h2>`) in the content: 25 26 ``` 27 {{ findRE "<h2.*?>(.|\n)*?</h2>" .Content }} 28 ``` 29 30 You can limit the number of matches in the list with a third parameter. The following example shows how to limit the returned value to just one match (or none, if there are no matched substrings): 31 32 ``` 33 {{ findRE "<h2.*?>(.|\n)*?</h2>" .Content 1 }} 34 <!-- returns ["<h2 id="#foo">Foo</h2>"] --> 35 ``` 36 37 {{% note %}} 38 Hugo uses Go's [Regular Expression package](https://golang.org/pkg/regexp/), which is the same general syntax used by Perl, Python, and other languages but with a few minor differences for those coming from a background in PCRE. For a full syntax listing, see the [GitHub wiki for re2](https://github.com/google/re2/wiki/Syntax). 39 40 If you are just learning RegEx, or at least Go's flavor, you can practice pattern matching in the browser at <https://regex101.com/>. 41 {{% /note %}} 42 43 44 [partials]: /templates/partials/ 45 [`plainify`]: /functions/plainify/ 46 [toc]: /content-management/toc/ 47 [`urlize`]: /functions/urlize