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

Home » Public Forums » archive » Re: splitting strings
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: splitting strings [message #42445 is a reply to message #42443] Thu, 03 February 2005 12:53 Go to previous messageGo to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
David Fanning wrote:
> Benjamin Hornberger writes:
>
>
>> I would like to split a string by whitespace characters, while anything
>> between quotes should be recognized as one elements (even if it contains
>> whitespace). Let's say I have the string
>>
>> 'cat dog "ground hog" bird'
>>
>> I want to split it into ['cat', 'dog', 'ground hog', 'bird']. Does
>> anybody have a general algorithm or a function to do that? Or do I have
>> to work it out myself?
>
>
> str = 'cat dog "ground hog" bird'
> print, StrSplit(str, "", /Extract)
>
> Cheers,
>
> David

Doesn't work, the result is an empty string.

If you use " " as pattern for strsplit (the default), I get ['cat',
'dog', '"ground', 'hog", 'bird'], which is not what I want either.

Benjamin
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Array extraction, multiple slices from paired values
Next Topic: Drawing lines on image and obtaining points of intersection

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

Current Time: Fri Oct 10 14:07:44 PDT 2025

Total time taken to generate the page: 1.19932 seconds