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.
--
Vladimir Botka
--
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/20220621055343.5adaefbc%40gmail.com.
pgp7wqTwtKv5M.pgp
Description: OpenPGP digital signature
