# Ansible regex filter along with\_items

**URL:** <https://forum.ansible.com/t/ansible-regex-filter-along-with-items/27430>\
**Category:** Ansible Project\
**Created:** [May 2, 2018, 3:05pm UTC](https://forum.ansible.com/t/ansible-regex-filter-along-with-items/27430 "2018-05-02T15:05:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madushan\_Chathuranga](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@Madushan\_Chathuranga](https://forum.ansible.com/u/Madushan_Chathuranga)\
**Post date:** [May 2, 2018, 3:05pm UTC](https://forum.ansible.com/t/ansible-regex-filter-along-with-items/27430/1 "2018-05-02T15:05:40Z")

</div>

**Hi,**

**I’m kinda new to ansible seeking helop with below scenario. what I’m trying to do is iterate over the array ‘access\_key\_ids’ and run regex\_search filter. for the regex\_search filter argument is ‘item’ which is the variable from with\_items. It does not work this way below is what I’m trying.**

**name:** Set Fatcs

**block:**

_# extract access key ids from get event response_

- **set\_fact:**

**event\_response\_access\_key\_ids:** “{{event\_response\_access\_key\_ids}} + [{{event\_response.content | regex\_search(item)}}]”

**with\_items:** “{{access\_key\_ids}}”

_# check if the response contains access key id for the license_

- **set\_fact:**

**scwx\_output:** “{{ (event\_response\_access\_key\_ids | length \> 0 ) | ternary(event\_response, ‘License Key does not match with available sensors’)}}”

**when:** event\_response.json is undefined

**It gives**  **event\_response\_access\_key\_ids as empty. but when I**  **hard code**  **a value instead of ‘item’ it works**

**Thanks.**
