Nested variables and Regex...

Dear community,

sorry that I have to bother you but I don’t get it.

My goal is to create a nested variables which consists of a static text and two other variables. The thing is, the two variables may contain characters that should be “removed”.

This is my (java) regex: [\s,.;-_]+

And I wanted to do something like that:

elasticsearchclustername: "es{{ server_hostname | regex_replace('([\\s\\,\\.\\;\\-\\_]+)') }}{{ software_version | regex_replace('([\\s\\,\\.\\;\\-\\_]+)') }}"

After that I use the new variable (elasticsearchclustername) within different jinja2 templates. But that is when I get an “recursive loop detected in template” error.

I really hate regex and I would appreciate any input.

Thanks in advance.

René

Here you go:

elasticsearchclustername: “es{{ (server_hostname + software_version) | regex_replace(‘[ .,;-]+’, ‘’) }}”

Thanks for helping me out. :slight_smile:

Sadly it looks like that the construct itself is the issue and not the regex. After I resolved the “recursive loop detected in template” issue, I ran into another one. I have to dig into that one first to resolve this entirely.

Nevertheless thanks for your help. :slight_smile: