# filter to exclude a string pattern ?

**URL:** <https://forum.ansible.com/t/filter-to-exclude-a-string-pattern/19295>\
**Category:** Ansible Project\
**Created:** [September 18, 2015, 12:52am UTC](https://forum.ansible.com/t/filter-to-exclude-a-string-pattern/19295 "2015-09-18T00:52:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [September 18, 2015, 12:52am UTC](https://forum.ansible.com/t/filter-to-exclude-a-string-pattern/19295/1 "2015-09-18T00:52:04Z")

</div>

Hi, I have the bellow values written from some vars , they all have a pattern ‘xyz\_’ on front :

xyz\_name\_1  
xyz\_name\_2

xyz\_special\_3

xyz\_other\_4

Is there a filter I can use to exclude the ‘xyz\_’ pattern so my values will be more clear like :

name\_1  
name\_2

special\_3

other\_4

???

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 23, 2015, 11:29pm UTC](https://forum.ansible.com/t/filter-to-exclude-a-string-pattern/19295/2 "2015-10-23T23:29:10Z")

</div>

you can use the replace filter {{var|replace('xyz\_','')}}
