Mark Galbreath <[EMAIL PROTECTED]> wrote: > Close enough to perl, I hope... > > I'm trying to string the filename from the path: > > /dir/subdir/file.ext => file.ext > > with > > /\w+\.\w+$/ > > and am getting the entire path returned. I am falling asleep reading the > perldoc regex "intro," "tutorial," full doc, and even Jeffrey Friedl's > "Mastering Regular Expressions." This can't be this difficult nor unusual! > Why can't I find an example somewhere or get this to work? Better yet, > somebody please profer a solution? :-)
Well, I'd suggest using File::Basename for this, since that's nice and portable and deals with a lot of edge cases with funny filenames, it's part of the standard perl distribution, etc. But if I understand what you're trying to do, I think it's m{^(?:.*/)?([^/]+)$}; After that, the filename itself should be in $1. - Tyler