# how to extract a substring from a variable value inside a template

**URL:** <https://forum.ansible.com/t/how-to-extract-a-substring-from-a-variable-value-inside-a-template/21847>\
**Category:** Ansible Project\
**Created:** [June 23, 2016, 7:18pm UTC](https://forum.ansible.com/t/how-to-extract-a-substring-from-a-variable-value-inside-a-template/21847 "2016-06-23T19:18:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nino\_Pineda](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Nino\_Pineda](https://forum.ansible.com/u/Nino_Pineda)\
**Post date:** [June 23, 2016, 7:18pm UTC](https://forum.ansible.com/t/how-to-extract-a-substring-from-a-variable-value-inside-a-template/21847/1 "2016-06-23T19:18:00Z")

</div>

Hello,

Does someone knows how to extract a substring from a variable?

For example;

name: repo-name/some\_dir  
subdir: /some\_dir

i want to perform in a template something like:

ansible-pull -d /{{ name - subdir }}

and pull contents will be place in /repo-name

is this possible?

Thank you!
