How to extract Site URL Name from List Item

Here is an example of a Site URL

We have a site collection called Projects and site called 17. From the task list we want to know what the site name is that the task list is on so we can do filtering from BCS large lists that contain many project ID’s. To do this insert the built in field called Path to a custom list view in SPD and parse out the site url name.

substring-after(@FileDirRef, ‘/projects/’)    retures this:  17/Lists/Tasks

substring-before(substring-after(@FileDirRef, ‘/projects/’) , ‘/Lists/Tasks’)  resurns this:  /sites/projects/17

Put them together and it returns the no 17
select="substring-before(substring-after(@FileDirRef, ‘/projects/’) , ‘/Lists/Tasks’)"