Replace with regex?

How can I replace text with regex in Hugo’s HTML template?

Code

{{ replace “abc abc” “^abc” “def” }}

Expected

def abc

You can not.

OK. Thanks.

I know you asked this a while ago, but now you can actually do regex replace content: https://gohugo.io/functions/replacere/

1 Like

Thanks @maximilian-lindsey! The nice thing about the replaceRE function is that you can also chain it multiple times, which you can’t do with replace. It would be nice if replace also supported this.