Why throw regex at such a simple problem?
$source = "/i/am/a/path.txt";
$pos = strrpos($source, '/');
$result = substr($source, $pos === FALSE ? 0 : $pos);
EDIT: I have not tried this -- I don't have a working PHP server handy. There might be an off-by-one error with substr and strrpos, but if that's the case you just add or subtract one from $pos.
EDIT2: Here's a backslash version:
$source = "\\i\\am\\a\\path.txt";
$pos = strrpos($source, '\\');
$result = substr($source, $pos === FALSE ? 0 : $pos);