Re[2]: [PHP] Reg Ex
| From: | ANR Daemon | Date: | Mon, 10 Nov 2008 19:35:08 +0000 |
| Subject: | Re[2]: [PHP] Reg Ex | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-283190@lists.php.net to get a copy of this message | ||
Greetings, "Boyd, Todd M.".
In reply to Your message dated Friday, October 31, 2008, 17:51:59,
> Someone suggested pathinfo() already... and brought up the issues of
> extensions < 3 chars and files with no "basename" (i.e., ".htaccess")...
> Checked out www.php.net/pathinfo, and ran a demo on my own machine. I
> can't test the .htaccess problem, since I'm running Windows (and M$
> won't let you have files that start with "."), but I tested it with
> "a.b.c.d" and the extension was returned as "d". Basename was
> "a.b.c".
M$ permissions has nothing to do with your problem.
Notepad - File - Save as - .htaccess, File type: All files
Here you got it.
But it's easier to use more straight tools than stupid explorer.
> Sounds like it will do exactly what you are trying to accomplish. For
> what it's worth, if I were to do it with a regular expression, I would
> use:
> $filename = "us.123.kyle.20081029.zip";
> preg_match('/(.*)\..*$/', $filename, $match);
I should correct you to
#^((.+)(\.[^\.]+)?)$#
Results will be
1 => Filename
2 => Basename
3 => Extension
--
Sincerely Yours, ANR Daemon <anrdaemon@freemail.ru>