Re[2]: Reg Ex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux