in reply to dir / file split

Hi,
should be OK...
$file_path =~ /(.*)\/([^/]+)$/;
(update: Explanation: the second means: one or more of everything but a slash up to the end of the string.)

if you are even more paranoid ;-)
Regards,
svenXY

Replies are listed 'Best First'.
Re^2: dir / file split
by oha (Friar) on Sep 28, 2007 at 13:26 UTC
    note: for the string "foo/bar/" the OP's RE will match ("foo/bar",""), but your will not match at all.
    Also there's no need to worry about greedyness in the OP case: the backtracking for "foo/bar/cuz" will start tring to match "foo/bar/cuz" then "foo/bar/cu", "foo/bar/c" and so on till "foo/bar", which allow to finish correctly the RE in that order.
    use re 'debug'; could help

    Oha

Re^2: dir / file split
by camelcom (Sexton) on Sep 28, 2007 at 13:17 UTC
    ...have updated my script - thanks Sven