Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

Re: [PHP3] Path From: Adam Trachtenberg (adam <email protected>)
Date: 01/26/99

> > Now, for the second half of the question... since I'm horrible at regex,
> > does anybody know the regular expression that will take this:
> >
> > /home2/users/whatever/
> >
> > and extract 'whatever'

$path = '/a/b/c/d/e/f/g/gimmethis/';
ereg('/?([^/]+)/?$',$path,$directory);
echo "$directory[1]<BR>";

If you know that the path will always have a leading and trailing /, then
you can remove the ?s from the pattern in ereg().

-adam

-- 
/ adam maccabee trachtenberg | visit college life online \
\ adam <email protected>           | http://www.student.com    /

-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>