Re: Re: splitting a string
| From: | Ashley Sheridan | Date: | Tue, 05 Jan 2010 15:20:19 +0000 |
| Subject: | Re: Re: splitting a string | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-300820@lists.php.net to get a copy of this message | ||
On Tue, 2010-01-05 at 16:18 +0100, Daniel Egeberg wrote:
> On Tue, Jan 5, 2010 at 16:09, Shawn McKenzie <nospam@mckenzies.net> wrote:
> > Of course this doesn't work for something like 'My.Word.Document.docx'
> > or 'archive_v2.0.1.tar.gz', but I don't know what will with extensions
> > being variable length and possibly composed of multiple periods.
>
> I suppose a solution to that could be having a list of known file
> extensions and use that while falling back to one of the methods given
> in this thread if there is no match in the list. Of course you would
> then have to check .tar.gz before .gz if you're just iterating through
> a list. You might also just choose the longest match (in terms of
> number of periods).
>
That was my thought on how operating systems did it. If it maybe can't
find a matching pattern, then it can fall back to matching anything
after the last period.
It always puzzles me, because some.archive.tar.gz is a valid file, but
the extension is .tar.gz and the filename is some.archive. I guess it
must compare the full filename to a list of knowns, and then try it's
best after that.
Thanks,
Ash
http://www.ashleysheridan.co.uk