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

Home » Public Forums » archive » IDL_STRING.split vs strsplit
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL_STRING.split vs strsplit [message #94765] Mon, 02 October 2017 03:11 Go to next message
trisb is currently offline  trisb
Messages: 18
Registered: November 2010
Junior Member
Hi everyone,

I have the following string

mystring = "MY.NESTED.FILENAME.ARGH"

What I want to do is split the string into substrings with the dot as the dividing character. Two methods area available but only one delivers:

This works:

IDL> out = strsplit(mystring,'.',/extract)
IDL> help,out
OUT STRING = Array[4]
IDL> print,out
MY NESTED FILENAME ARGH


This doesn't:

IDL> out = mystring.split('.')
IDL> help,out
OUT STRING = Array[24]
IDL> print,out



Any clue as to why the second one behaves that way? Note that this only happens with the dot, so I must be missing something fundamental.

Thanks,
F.
Re: IDL_STRING.split vs strsplit [message #94766 is a reply to message #94765] Mon, 02 October 2017 05:14 Go to previous messageGo to next message
Burch is currently offline  Burch
Messages: 28
Registered: December 2013
Junior Member
On Monday, October 2, 2017 at 5:11:45 AM UTC-5, trisb wrote:
> Hi everyone,
>
> I have the following string
>
> mystring = "MY.NESTED.FILENAME.ARGH"
>
> What I want to do is split the string into substrings with the dot as the dividing character. Two methods area available but only one delivers:
>
> This works:
>
> IDL> out = strsplit(mystring,'.',/extract)
> IDL> help,out
> OUT STRING = Array[4]
> IDL> print,out
> MY NESTED FILENAME ARGH
>
>
> This doesn't:
>
> IDL> out = mystring.split('.')
> IDL> help,out
> OUT STRING = Array[24]
> IDL> print,out
>
>
>
> Any clue as to why the second one behaves that way? Note that this only happens with the dot, so I must be missing something fundamental.
>
> Thanks,
> F.

Unlike STRSPLIT() the SPLIT method requires the argument to be in the format of a regular expression. Try this instead:

IDL> out = mystring.split('\.')
IDL> help, out
OUT STRING = Array[4]
IDL> print, out
MY NESTED FILENAME ARGH

More on regular expressions: https://www.harrisgeospatial.com/docs/learning_about_regular _e.html

-Jeff
Re: IDL_STRING.split vs strsplit [message #94767 is a reply to message #94766] Mon, 02 October 2017 13:05 Go to previous message
trisb is currently offline  trisb
Messages: 18
Registered: November 2010
Junior Member
Thanks for the swift reply and explanation, Jeff. Much appreciated.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: mystring.split('.') versus substring(mystring,'.',/extract)
Next Topic: new IDL version can only be downloaded by license administrators

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

Current Time: Wed Oct 08 07:16:37 PDT 2025

Total time taken to generate the page: 0.00471 seconds