Hi  Vladimir ,

I got it by using the  join  -  s1_34: "{{ [[1], [3, 4]]| map('map', 
'extract', arr)| join(',')}


On Sunday, October 15, 2023 at 1:08:39 AM UTC+5:30 Vladimir Botka wrote:

> On Sat, 14 Oct 2023 10:32:51 -0700 (PDT)
> Veera <svee...@gmail.com> wrote:
>
> > Is there a way to combine the 2 positional values ...
> > to print like below
> > - two
> > - four five
>
> Split the string and trim the items
>
> arr: "{{ myline|split(',')|map('trim') }}"
>
> gives
>
> arr:
> - This line is a test
> - two
> - three
> - four
> - five
> - '6'
> - seven
>
> A list of lists the structure that describes what you want
>
> s1_34: "{{ [[1], [3, 4]]|
> map('map', 'extract', arr)|
> map('join', ' ') }}"
>
> gives
>
> s1_34:
> - two
> - four five
>
> You can substitute *arr* in *s1_34* if you want a 'one-liner'.
>
>
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/15ad36b7-c542-4cc1-975e-d37bfd3b13f0n%40googlegroups.com.

Reply via email to