I\'m trying to write a regex that will parse out the directory and filename of a fully qualified path using matching groups.
so...
/
Try this:
/^(\/([^/]+\/)*)(.*)$/
It will leave the trailing slash on the path, though.
What language? and why use regex for this simple task?
If you must:
^(.*)/([^/]*)$
gives you the two parts you wanted. You might need to quote the parentheses:
^\(.*\)/\([^/]*\)$
depending on your preferred language syntax.
But I suggest you just use your language's string search function that finds the last "/" character, and split the string on that index.