extracting all but... [message #46307] |
Fri, 18 November 2005 18:15  |
Koh Leong Tah
Messages: 11 Registered: May 2005
|
Junior Member |
|
|
Hi All,
I was wondering how I can extract all but a constant string from an
array of strings?
basically, I have an array of filenames with a particular directory
prefixed to each of the filenames like so:
files =
['/some/constant/directory/file1','/some/constant/directory/ file2',
etc.]
and would like to have just an array of the filenames without the
prefixed directory name so that the result looks like:
files = ['file1', 'file2', etc.]
any ideas?
Cheers,
KL
|
|
|
Re: extracting all but... [message #46443 is a reply to message #46307] |
Sun, 20 November 2005 08:25  |
Robert Moss
Messages: 74 Registered: February 1996
|
Member |
|
|
kl_tah@hotmail.com wrote:
> Hi All,
>
> I was wondering how I can extract all but a constant string from an
> array of strings?
> basically, I have an array of filenames with a particular directory
> prefixed to each of the filenames like so:
>
> files =
> ['/some/constant/directory/file1','/some/constant/directory/ file2',
> etc.]
>
> and would like to have just an array of the filenames without the
> prefixed directory name so that the result looks like:
>
> files = ['file1', 'file2', etc.]
>
>
> any ideas?
>
> Cheers,
> KL
>
You want to use the FILE_BASENAME function. It will extract the file
name in just the way you require. You might also look at the
FILE_DIRNAME function. It can also be handy for the types of
manipulations you are doing here.
--
Robert Moss, PhD
|
|
|