This overview is worthy of its own paragraph in the ansible docs!
On 2022-06-21 (Tue) 05:53, Vladimir Botka wrote:
On Mon, 20 Jun 2022 13:58:42 -0700 (PDT) "[email protected]" <[email protected]> wrote:... The search test does work with lists ... ... a list ["a", "b\t"] will get converted to the string, '["a", "b\\t"]'. ... I need to search for ...b\\t... in single quotes.I see. You're right. It's worth to test the escaping. The simplest case is when the items are double-quoted and *regex* is variable - debug: msg: "{{ _list is search(regex) }}" vars: _list: ["a", "b\t"] regex: 'b\\t' Additional escaping, because of the outside double-quotes, is needed when *regex* is value - debug: msg: "{{ _list is search('b\\\\t') }}" vars: _list: ["a", "b\t"] Additional escaping is also needed when the items are single-quoted and *regex* is variable. This time because of '\\' is needed after evaluation - debug: msg: "{{ _list is search(regex) }}" vars: _list: ['a', 'b\t'] regex: 'b\\\\t' Finally, one more additional escaping is needed when you put the *regex* as a value - debug: msg: "{{ _list is search('b\\\\\\\\t') }}" vars: _list: ['a', 'b\t'] All tasks above return True.
-- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b205fe10-d076-386c-3dff-0343684e0d50%40gmail.com.
OpenPGP_0x266713D4E6EF488D.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
