I’m translating some logic from javascript to hugo, and I hit a bit of a speedbump.
How can I access my named capture groups in a findRE? I know I haven’t nailed the regex yet, but I need to know this part first. I have two named groups at the moment: name and file. How can I access these? $result returns an array it seems, but no subgroups. They don’t have to be named, if that helps…
My regex looks like this:
{{ $results := findRE `~~(?P<name>\S*)\n(?P<file>[\s\S]*?)(?:~~|$)` .Inner }}
The string looks like this:
~~.html*
<h1>Random header</h1>
<p>
Random content
</p>
~~.css
h1 { font-size: 80px; }