findRE
Syntax
findRE PATTERN INPUT [LIMIT]
By default all matches will be included. The number of matches can be limited with an optional third parameter.
The example below returns a list of all second level headers (<h2>
) in the content:
{{ findRE "<h2.*?>(.|\n)*?</h2>" .Content }}
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):
{{ findRE "<h2.*?>(.|\n)*?</h2>" .Content 1 }}
<!-- returns ["<h2 id="#foo">Foo</h2>"] -->