On Sat, 14 Oct 2023 10:32:51 -0700 (PDT)
Veera <sveem...@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/20231014213815.4d34a4de%40gmail.com.

Attachment: pgpayI00Z88D5.pgp
Description: OpenPGP digital signature

Reply via email to