Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Let's say you have a directory:
/rootdir/sub1/sub2/sub3/sub4/
How would I strip off JUST the last subdir, sub4? Of course, the dir could be called anything, like "/rootdir/sub funky ---doodash/la la la/Proposal for Buttering My Feet" and I would still want to strip off "Proposal for Buttering My Feet", and be 5 or more times long.
Any idea? I figure it's a reg ex like "Look for the last / that isn't the last character and take away everything to the right of it, including itself"
Thanks very much!!!!
/rootdir/sub1/sub2/sub3/sub4/
How would I strip off JUST the last subdir, sub4? Of course, the dir could be called anything, like "/rootdir/sub funky ---doodash/la la la/Proposal for Buttering My Feet" and I would still want to strip off "Proposal for Buttering My Feet", and be 5 or more times long.
Any idea? I figure it's a reg ex like "Look for the last / that isn't the last character and take away everything to the right of it, including itself"
Thanks very much!!!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regular Expression Help
by Fletch (Bishop) on Nov 18, 2005 at 19:58 UTC | |
Re: Regular Expression Help
by ikegami (Patriarch) on Nov 18, 2005 at 20:45 UTC | |
Re: Regular Expression Help
by pg (Canon) on Nov 18, 2005 at 20:16 UTC | |
Re: Regular Expression Help
by ikegami (Patriarch) on Nov 18, 2005 at 20:18 UTC | |
Re: Regular Expression Help
by Anonymous Monk on Nov 19, 2005 at 00:30 UTC | |
Re: Regular Expression Help
by ercparker (Hermit) on Nov 19, 2005 at 04:51 UTC | |
Re: Regular Expression Help
by TedPride (Priest) on Nov 18, 2005 at 23:38 UTC | |
Re: Regular Expression Help
by ptum (Priest) on Nov 18, 2005 at 19:57 UTC | |
by Anonymous Monk on Nov 18, 2005 at 20:09 UTC | |
by ptum (Priest) on Nov 18, 2005 at 20:17 UTC |
Back to
Seekers of Perl Wisdom