# Filter values

**URL:** <https://forum.ansible.com/t/filter-values/34394>\
**Category:** Ansible Project\
**Created:** [January 5, 2021, 2:39pm UTC](https://forum.ansible.com/t/filter-values/34394 "2021-01-05T14:39:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pravin\_V](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Pravin\_V](https://forum.ansible.com/u/Pravin_V)\
**Post date:** [January 5, 2021, 2:39pm UTC](https://forum.ansible.com/t/filter-values/34394/1 "2021-01-05T14:39:36Z")

</div>

Hello Everyone,  
I want to filter out the values after “:” so I can pass the RestAPI commands to add the devices.

- name: Split All - FIRST  
set\_fact:  
names\_list: “{{ get\_names.content.split(‘\n’) | regex\_replace(‘( =)’, ‘:’) }}”  
macs\_list: “{{ get\_macs.content.split(‘\n’) | regex\_replace(‘( =)’, ‘:’) }}”  
descriptions\_list: “{{ get\_descriptions.content.split(‘\n’) | regex\_replace(‘( =)’, ‘:’) }}”

- name: FileCreate  
lineinfile:  
path: debugfile.log  
insertafter: EOF  
create: yes  
line: “FIRST - {{ item.0 }}, SECOND - {{ item.1 }}, THIRD - {{ item.2 }}”  
loop: “{{ data[0]|zip(\*data[1:])|list }}”  
vars:  
data:

- ‘{{ names\_list }}’

- ‘{{ macs\_list }}’

- ‘{{ descriptions\_list }}’

Here’s the output of the lineinfile -

FIRST - sw01 GigabitEthernet0/0 IF-MIB.ifName: GigabitEthernet0/0, SECOND - sw01 GigabitEthernet0/0 IF-MIB.ifPhysAddress: 0001e896655b, THIRD - sw01 GigabitEthernet0/0 IF-MIB.ifDescr: GigabitEthernet 0/0

Please advise how can I split or filter the first part.

Thanks
