On Tue, 12 Jan 2021 02:35:42 -0800 (PST) Akshay Kumar <[email protected]> wrote:
> List1 : ['dba','admin','developer']
> List2 : [' user1: dba admin' , 'user2 : dba developer', 'user3 : operator']
>
> ... comparing above two list sets , the output should be
> user1
> user2
> as both users have dba/admin/developer item in there strings of list 1.
Try
- set_fact:
List3: "{{ List2|
select('search', my_regex1)|
map('regex_replace', my_regex2, my_replace)|
map('trim')|
list }}"
vars:
my_regex1: '{{ List1|join("|") }}'
my_regex2: '^(.*):(.*)$'
my_replace: '\1'
--
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/20210112124028.716cc273%40gmail.com.
pgpV_GZGBC9JD.pgp
Description: OpenPGP digital signature
