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

5,686 views
Skip to first unread message

hindenburg

unread,
Apr 1, 2014, 3:53:00 PM4/1/14
to ansible...@googlegroups.com
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.

I've been struggling with the replace filter.

{{ item.url | replace("*/", '')  }}

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

Scott Sturdivant

unread,
Apr 1, 2014, 4:05:34 PM4/1/14
to ansible...@googlegroups.com
Is the 'basename' filter what you're looking for?  http://docs.ansible.com/playbooks_variables.html#other-useful-filters


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/668e0f3c-217e-4881-babf-8f5223983214%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

hindenburg

unread,
Apr 1, 2014, 4:15:47 PM4/1/14
to ansible...@googlegroups.com
Yes - thanks Scott.
Reply all
Reply to author
Forward
0 new messages