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

Home » Public Forums » archive » removing substring from string array
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: removing substring from string array [message #53335 is a reply to message #53240] Mon, 02 April 2007 14:54 Go to previous messageGo to previous message
yp is currently offline  yp
Messages: 42
Registered: February 2005
Member
On Apr 2, 10:21 pm, rchug...@gmail.com wrote:
> Hi All,
>
> Does anyone know a quick way to remove the same prefix from all
> elements in a string array?
>
> Here is an example:
> start with string_array = ['dog.spot', 'dog.rover', 'dog.lucky']
>
> and get ['spot', 'rover', 'lucky']
>
> The only way I know I can do this is with a FOR loop and the
> STRSPLIT(string_array[i], '.', /EXTRACT) command. I am hoping someone
> could help me out with a much more efficient way if there is one.
>
> Thanks in advance,
> Ryan.


string_array = ['dog.spot', 'dog.rover', 'dog.lucky']
tmp=stregex(string_array,'dog.',length=L)
n = 100 ;set max number of characters to be extracted
new_array=transpose((strmid(string_array, L, n))[0,*])

Be cautious when you have a huge string_array...
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: rotate and transpose images in xobjviewer
Next Topic: General help

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

Current Time: Sat Oct 11 06:44:36 PDT 2025

Total time taken to generate the page: 1.67770 seconds