Escaping a single backslash in the "replace" part of a regex_replace

Hi,
I need to replace a dot in a string with a “!”. I am using “regex_replace” but am unable to get the regex to print a single backslash.

I have tried escaping it using double-backslash but that gives me 2 backslashes in the output. Interestingly escaping using 4 backslashes also gives 2 backslashes in the output - so could this be a bug?

Ansible version is 2.2.1.0

`

Your regex is fine, and there is really only one backslash in the output.
It's the escaping of debug that is fooling you.
Try adding this task and check the content:

    - copy:
        dest: /tmp/test
        content: "{{ ini }}"

Dick