Q:

How can I get a section of a string?

I'm trying to return the directories of a file/directory and also their directories. 
I have for example "this/iss/the/root/assets/images/icons/parent" which is the parent of "this/iss/the/root/assets/images/icons/parent/child.
This will be the root path this/iss/the/root and I want to get everything after the root path: assets/images/icons/examples' i.e. given the root, how can I extract all the directories after the root but before the child?
I have tried:
parent.lastIndexOf(root)

but it gives me the entire parent path.
Sorry this was very long winded. I've spent ages staring at my code none stop and it's nearly midnight!

A:

Try this:
    String str = "this/iss/the/root/assets/images/icons/parent/child";
    String root = "this/iss/the/root/";
    String rootRegex = root.replace("/", "\\/"); //escape fwd slashes
    String ptrnStr = "^" + rootRegex + "(.+)child\\Z";
    java.util.regex.Pattern ptrn = Pattern.compile(ptrnStr); 

    java.util.regex.Matcher mtchr = ptrn.matcher(str);

    if(mtchr.find())
    {
        String between = mtchr.group(1);
        System.out.println("FOUND:  " + between);
    }

