[Solved] Convert regex match array to string


I’m having trouble writing my sidebar content logic to fetch all files in current directory.
Github repository
My logic looks like this.
I want to do this
Problem lies in regex returning array, last parameter of where expects string

Longer story

.RelPermalink gives me the link to the current file as /topic/page.html. This means that if I go to http://wiremodforall.com/e2/the-editor.html, .RelPermalink gives me /e2/the-editor.html. My goal is to have a dynamic sidebar with content that mirrors its current directory’s files. I tried extracting the topic part out of /topic/page.html, but, as I have done in the code, {{$topic := findRE "[^/]+" .RelPermalink}} only returns an array (or slice?). I tried to do $topic[0], but that didn’t work. I think I need to actually convert $topic to a string, which I tried to look up but couldn’t find a single answer to…

But by all means, if anyone have a more elegant way of doing exactly what I’m trying to do, I’d be pleased with some enlightenment

:sunny: Inserting emoji only for the sake of the badge ( ͡° ͜ʖ ͡°)

EDIT: I’m sorry, I forgot to actually push my changes up to the repository, it is now updated

Try wrapping it in a call to index:

{{ $topic := index ( findRE "[^/]+" .RelPermalink ) 0 }}

Woooahhhh it actually worked, goddamn!
Starfall page
e2 page

Thanks alot man, I really appreciate it, been struggling for a while now