Given the string a/b/c/d
which represents a fully-qualified sub-directory I would like to generate a series of strings for each step up the parent tree, i.e.
One solution building on idea in this other question:
d/c/b/a
For instance in PHP use strrev($string )
(?=(/(?:\w+(?:/|$))+))
This give you
/c/b/a
/b/a
/a
Then reverse the matches with strrev($string )
This give you
a/b/c/
a/b/
a/
If you had .NET not PCRE you could do matching right to left and proably come up with same.