Replace characters

I need .Permalink value to not contains dot, space, hashtag, dollar sign, [ or ].
and I do nested replace, like bellow:

{{ replace (replace (replace (replace (replace .RelPermalink "." "-") "[" "-") "]" "-") "$" "-") "#" "-" }}

is it okay? I am new to hugo. Thank you.

You can use the replaceRE function instead, for example:

{{ replaceRE `[\s\.\$\[\]#]` "-" "a b.c[d$e]f#g" }}
a-b-c-d-e-f-g
1 Like

thank you very much

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.