Great thank you! Is there documentation somewhere on using '::' ? I've looked everywhere...
On Tuesday, September 12, 2023 at 9:40:05 AM UTC-4 Matt Martz wrote: > All you need is to use is slicing with a step: > > If my variable is `verylongvariable: s1i2v3e4l5` > > If I want `sivel`, I'd use: {{verylongvariable[::2]}} > > If I want `12345`, I'd use: {{verylongvariable[1::2]}} > > On Tue, Sep 12, 2023 at 8:35 AM Kathy L <lyon...@gmail.com> wrote: > >> I am trying to grab every other character in a very long variable, and >> placing it in another variable. This is what I have: >> >> set_fact: >> new_string: "{{ [ 0,2,4,6,8,10,12 ] | map('extract', verylongvariable) >> }}" >> >> I've also tried this: >> set_fact: >> new_string: "{{ [ 0,2,4,6,8,10,12 ] | map('extract', >> verylongvariable) }} | map('join', ',' | join('')) }} >> >> What I end up getting in the new_string is this: >> >> 'N', 'y', 'a', 'd'.... >> >> What I want is: >> >> Nyad.... >> >> I clearly am not understanding the join syntax. How do I use join to get >> the new variable? >> >> -- >> 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-proje...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/ec75223e-8d4a-4aa8-bbfa-2d78389d35fan%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/ec75223e-8d4a-4aa8-bbfa-2d78389d35fan%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Matt Martz > @sivel > sivel.net > -- 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/a2749a58-1aed-4652-91b3-3c727fa8b19an%40googlegroups.com.