# How to get the substring to the right of the last forward slash (/) of a string ?

**URL:** <https://forum.ansible.com/t/how-to-get-the-substring-to-the-right-of-the-last-forward-slash-of-a-string/14907>\
**Category:** Ansible Project\
**Created:** [April 1, 2014, 7:53pm UTC](https://forum.ansible.com/t/how-to-get-the-substring-to-the-right-of-the-last-forward-slash-of-a-string/14907 "2014-04-01T19:53:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hindenburg](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@hindenburg](https://forum.ansible.com/u/hindenburg)\
**Post date:** [April 1, 2014, 7:53pm UTC](https://forum.ansible.com/t/how-to-get-the-substring-to-the-right-of-the-last-forward-slash-of-a-string/14907/1 "2014-04-01T19:53:00Z")

</div>

I’m parsing a variable and am trying to see if it’s possible to get the substring to the right of the last forward slash of a string.  
[http://docs.ansible.com/playbooks\_variables.html#jinja2-filters](http://docs.ansible.com/playbooks%5fvariables.html#jinja2-filters)

[http://jinja.pocoo.org/docs/templates/#builtin-filters](http://jinja.pocoo.org/docs/templates/#builtin-filters)

I’ve been struggling with the replace filter.

{{ item.url | replace(“\*/”, ‘’) }}

Is it possible to get the part after the last forward slash?

---

<div class="post-metadata">

**Author:** ![Scott\_Sturdivant](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@Scott\_Sturdivant](https://forum.ansible.com/u/Scott_Sturdivant)\
**Post date:** [April 1, 2014, 8:05pm UTC](https://forum.ansible.com/t/how-to-get-the-substring-to-the-right-of-the-last-forward-slash-of-a-string/14907/2 "2014-04-01T20:05:34Z")

</div>

Is the ‘basename’ filter what you’re looking for? [http://docs.ansible.com/playbooks\_variables.html#other-useful-filters](http://docs.ansible.com/playbooks_variables.html#other-useful-filters)

---

<div class="post-metadata">

**Author:** ![hindenburg](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@hindenburg](https://forum.ansible.com/u/hindenburg)\
**Post date:** [April 1, 2014, 8:15pm UTC](https://forum.ansible.com/t/how-to-get-the-substring-to-the-right-of-the-last-forward-slash-of-a-string/14907/3 "2014-04-01T20:15:47Z")

</div>

Yes - thanks Scott.
