Re: Regex help?
- From: Jim Gibson <jgibson@xxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Jun 2005 08:55:12 -0700
In article <3MidndnjAp51pyLfRVn-vA@xxxxxxxxxxx>, Smarta55 Chris wrote:
> Can someone help me find the last n folders in a path,
> or the last n OUs in a fully qualified Netware name... for an app object,
> etc?
>
> Example:
> \\server\volume\share\folder\folder\folder
> I want to grab just the last 2 folders (including or excluding the \s), but
> sometimes there
> are 3 folders after the share, like in the example, and sometimes there are
> more.
>
> Same for an app object in eDirectory
> .appobject.dept.biz.site.county.state.tree
> How to I grab just the .site.county.state.tree OUs?
> Sometimes there are 5 OUs after the app object, and sometimes more.
> I want, I think, to start at the end of the string, and grab everything
> after the 4th dot from the end, but
> don't have a clue how to code this.
Try using the split function:
my @folders = split(/\\/,$path);
Then @folders[-2..-1] contains the last two directories in the path.
FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
.
- References:
- Regex help?
- From: Smarta55 Chris
- Regex help?
- Prev by Date: Regex help?
- Next by Date: IO::Socket->recv and ncurses xterm resize
- Previous by thread: Regex help?
- Next by thread: IO::Socket->recv and ncurses xterm resize
- Index(es):
Relevant Pages
|
|