# Jinja template regex search for a specific word or up to a specific character

**URL:** <https://forum.ansible.com/t/jinja-template-regex-search-for-a-specific-word-or-up-to-a-specific-character/33105>\
**Category:** Ansible Project\
**Created:** [June 5, 2020, 11:48pm UTC](https://forum.ansible.com/t/jinja-template-regex-search-for-a-specific-word-or-up-to-a-specific-character/33105 "2020-06-05T23:48:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![J111](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@J111](https://forum.ansible.com/u/J111)\
**Post date:** [June 5, 2020, 11:48pm UTC](https://forum.ansible.com/t/jinja-template-regex-search-for-a-specific-word-or-up-to-a-specific-character/33105/1 "2020-06-05T23:48:50Z")

</div>

I’m trying to search for a specific string from a var and while it finds it, it prints the whole line and not the exact match I’m looking for. I’m running ansible 2.9

Here is what it finds: **Interface GigabitEthernet0/1 “outside1”, is up, line protocol is up**

And what I’m looking for is everything up to **",** or better yet any specific word in that line **Interface GigabitEthernet0/1 “outside1”,**

Here is my template:

```auto
    {% for interface in show_interface.stdout_lines[0] %}
    {% if interface | regex_findall('Interface*.*\"\,',multiline=True) %}
    {{interface | string}}
    {% endif %}
    {% endfor %}

```

```auto
Here is my ansible-playbook task:

```

```auto
---
- name: execute firewall interface review
  asa_command:
    commands:
      - show interface | grep up
  register: show_interface

- name: print var data
  debug:
   var: show_interface.stdout_lines

- name: format interface data with template
  template:
    src: firewall_format.j2
    dest: ./firewall_interface_facts.txt
  delegate_to: localhost
'''

```
