# how to fetch substring from vairbale or ansible vriable or facts

**URL:** <https://forum.ansible.com/t/how-to-fetch-substring-from-vairbale-or-ansible-vriable-or-facts/33617>\
**Category:** Ansible Project\
**Created:** [August 14, 2020, 5:40pm UTC](https://forum.ansible.com/t/how-to-fetch-substring-from-vairbale-or-ansible-vriable-or-facts/33617 "2020-08-14T17:40:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sameer\_Modak](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sameer_modak/32/5180_2.png) [@Sameer\_Modak](https://forum.ansible.com/u/Sameer_Modak)\
**Post date:** [August 14, 2020, 5:40pm UTC](https://forum.ansible.com/t/how-to-fetch-substring-from-vairbale-or-ansible-vriable-or-facts/33617/1 "2020-08-14T17:40:50Z")

</div>

Hello Team,

How can we check if variable demo01 has 01 in it in ansible. i have server with hostanme server01 and server02 i want some task to be applied to only 01 machines how can i do it.

---

<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 14, 2020, 5:50pm UTC](https://forum.ansible.com/t/how-to-fetch-substring-from-vairbale-or-ansible-vriable-or-facts/33617/2 "2020-08-14T17:50:38Z")

</div>

[https://docs.ansible.com/ansible/latest/user\_guide/intro\_patterns.html](https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html)
