Backslashes in regex_replace #33202
Labels
affects_2.5
This issue/PR affects Ansible v2.5
bug
This issue/PR relates to a bug.
support:core
This issue/PR relates to code supported by the Ansible Engineering Team.
ISSUE TYPE
COMPONENT NAME
Core
ANSIBLE VERSION
SUMMARY
While I was upgrading from Ansible 2.3 to 2.4 I came across some changes in how backslashes are used to escape characters in
regex_replace
filter, so I made a little test playbook to show all the correct ways you can use backslashes. I told @abadger that I will make an issue for this, so here it is.STEPS TO REPRODUCE
Here is a test playbook:
and the template:
These are all the combination I could think of that work correctly. The output of running this playbook (with
-D
to be able to see results of thetemplate
module):EXPECTED RESULTS
Results mostly look as expected:
regex_replace
)ACTUAL RESULTS
Only strange thing is that inside templates you can use both double and single quotes inside a regex, but you have to use double quotes for back reference, which means both of these lines work in templates
In my opinion the second line feels like a bug and it should be consistent.
The text was updated successfully, but these errors were encountered: