# Regular expression to match output that doesn't contain a word

**URL:** <https://forum.ansible.com/t/regular-expression-to-match-output-that-doesnt-contain-a-word/35572>\
**Category:** Ansible Project\
**Created:** [August 1, 2021, 9:32pm UTC](https://forum.ansible.com/t/regular-expression-to-match-output-that-doesnt-contain-a-word/35572 "2021-08-01T21:32:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chr00ted](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chr00ted/32/2188_2.png) [@chr00ted](https://forum.ansible.com/u/chr00ted)\
**Post date:** [August 1, 2021, 9:32pm UTC](https://forum.ansible.com/t/regular-expression-to-match-output-that-doesnt-contain-a-word/35572/1 "2021-08-01T21:32:59Z")

</div>

I have a play that runs against several switches and returns the output of:

- name: show int desc  
ios\_command:  
commands:
- “sh interfaces description | inc {{ mac\_addr }}”  
register: printout

Is there a way to exclude results from switches that return results containing the string “UPLINK”?

Hopefully someone can point me in the right direction, I’ve been playing with regex\_findall in my testing trying to exclude any results that contain UPLINK using:  
^((?!UPLINK).)\*$

I get allot of errors such as:  
unexpected templating type error or template error while templating string: unexpected

IE: don’t display the results from the results from switches like these examples:

ok: [switch20] =\> {

“printout”: {

“changed”: false,

“failed”: false,

“stdout”: [

“Gi1/0/25 up up UPLINK”

],

“stdout\_lines”: [

[

“Gi1/0/25 up up UPLINK”

so hopefully it would only display this switch:

ok: [switch9] =\> {

“printout”: {

“changed”: false,

“failed”: false,

“stdout”: [

“Gi1/0/42 up up SEG 12 “

],

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 2, 2021, 3:28am UTC](https://forum.ansible.com/t/regular-expression-to-match-output-that-doesnt-contain-a-word/35572/2 "2021-08-02T03:28:39Z")

</div>

I’m a bit rusty on the IOS constructs but given that you are already piping things using “inc” (which is short for “include”), there is also “exclude”, maybe adding that works?
