Given the examples
/foo/bar/foobar/user1/somethingelse
/foo/bar/barfoofoo/user2/blabla/blah/bluh
I'm trying to extract user1
and user2
. I know that both of their grandparents is bar
, and I know that they're the 4th item in the path. The length after them is variable and their parent folder is also variable. I tried using lookbehind regexes, but because foobar and barfoofoo are of different length, I couldn't figure this out.