comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: extracting all but...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: extracting all but... [message #46306 is a reply to message #46305] Fri, 18 November 2005 18:50 Go to previous message
guillaume.drolet.1 is currently offline  guillaume.drolet.1
Messages: 20
Registered: July 2005
Junior Member
kl_tah@hotmail.com a écrit :

> 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


Dear KL,

As a solution, I would use the 'STRSPLIT' function with the /EXTRACT
keyword and '/' as a delimiter. It will return a string array
containing 4 string: [some constant directory file2].
For example, inside a loop:

string_arr = strsplit(files[i],'/',/extract)

Then it' easy to get the last element of the array and put it in
another array. I would repeat the operation for all your path+file.

Gui
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Version control for IDL software
Next Topic: Re: extracting strings between ' '

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 17:54:14 PDT 2025

Total time taken to generate the page: 1.03846 seconds