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
On 8 March 2017 at 12:40, 'akuma d' via Ansible Project
<[email protected]> wrote:
> 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
>
>
> ---
> - name: install MQ 8
> hosts: 192.168.90.84
> vars:
> qmgr: PAAA.QMGR
> tasks:
> - debug:
> msg: "{{ ini }}"
> vars:
> ini: "{{ qmgr | regex_replace('[.]','\\!') }}"
>
>
>
> Here is the output:
>
> TASK [debug]
> *******************************************************************
> ok: [192.168.90.84] => {
> "msg": "PAAA\\!QMGR"
> }
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6308c90f-8ac5-42d0-9ba6-ed8ba4841eda%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Dick Visser
Sr. System & Network Engineer
GÉANT
Want to join us? We're hiring: https://www.geant.org/jobs
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMcs3PPA9TvALKcch7id2mhs_5P4g0vtgw1Q%2BYBBtfGCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.