Escaping special characters in regex_replace with '\' fails with: unknown escape character

ansible: 2.10.5 (with pip3 install)
python version = 3.9.1+ (default, Jan 20 2021, 14:49:22) [GCC 10.2.1 20210110]

Escaping special characters in the searched string such as the following should be simply done with '':

  • ’ → '
  • ( → (
  • , → ,
  • ) → )

However, it seems to be impossible to perform this task with a single '' or even a double ‘\’; for instance, running the following playbook fails:


---
- name: Escaping special characters in regex_replace fails
hosts:
- localhost
strategy: debug
vars:
searched_string: "('string_a', 'string_b'),('string_c', 'string_d')"
tasks:
- name: Escaping with '
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing? - Result expected is “string_a@string_b,string_c@string_d”
set_fact:
replaced_string: "{{ searched_string |
regex_replace('(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing? - Result expected is "string_a@string_b,string_c@string_d"
set_fact:
replaced_string: "{{ searched_string |
regex_replace('\(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing? - Result expected is “string_a@string_b,string_c@string_d”
set_fact:
replaced_string: "{{ searched_string |
regex_replace('(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing? - Result expected is "string_a@string_b,string_c@string_d"
set_fact:
replaced_string: "{{ searched_string |
regex_replace('\(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing? - Result expected is “string_a@string_b,string_c@string_d”
set_fact:
replaced_string: "{{ searched_string |
regex_replace('(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing? - Result expected is "string_a@string_b,string_c@string_d"
set_fact:
replaced_string: "{{ searched_string |
regex_replace('\(
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing? - Result expected is "string_a@string_b,string_c@string_d"
set_fact:
replaced_string: "{{ searched_string |
regex_replace('\(
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?,
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)
leads to:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in ‘escape_special_characters_in_regex_replace.yml’: line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('(

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?]+)

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?([^

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:

b702431fec70586338fe4dcb8fe784cd

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?)', ‘\1@\2’) }}"
^ here


I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
...

leads to:


ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
found unknown escape character

The error appears to be in 'escape_special_characters_in_regex_replace.yml': line 16, column 53, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

replaced_string: "{{ searched_string |
regex_replace('\(

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\, 

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?([^

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?]+)

I thought about using the jinja2 'replace' filter to remove all special characters first, but that would just be throwing the can down the road, right? ;-)

What am I missing?\)', '\1@\2') }}"
^ here

I thought about using the jinja2 ‘replace’ filter to remove all special characters first, but that would just be throwing the can down the road, right? :wink:

What am I missing?

I meant kicking …, but you got the idea.

Hi,

the problem is that you're inside a YAML " " string, which already
interprets escaping.

Try using `>-` or something like that (https://yaml-multiline.info/)
instead of double quotes for the string that's templated, like

       replaced_string: >-
           {{ searched_string | regex_replace(
                '\(\'([^\']+)\'\, \'([^\']+)\'\)', '\\1@\\2') }}

Then it should work.

(Alternatively, if you use " ", you need to double escape - which is
extremely ugly to read.)

Cheers,
Felix

FWIW, create lists and join the items

    - set_fact:
        replaced_string: "{{ searched_lists|
                             map('join', '@')|list|
                             join(',') }}"
      vars:
        pleft: '\('
        pright: '\)'
        bleft: '['
        bright: ']'
        searched_lists: "{{ searched_string|
                            regex_replace(pleft, bleft)|
                            regex_replace(pright, bright) }}"

This simplified version gives the same result

    - set_fact:
        replaced_string: "{{ searched_lists|
                             map('join', '@')|list|
                             join(',') }}"
      vars:
        searched_lists: "{{ '[' ~ searched_string ~ ']' }}"

@Felix Fontein
I tried to replace the double-quotes with:

  • -: “An unhandled exception occurred while templating”

  • '>: “An unhandled exception occurred while templating”

@Vladimir Botka
Fantastic :slight_smile:
I chose the last version.