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

Home » Public Forums » archive » splitting difficult(?) strings
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
splitting difficult(?) strings [message #28758] Tue, 08 January 2002 09:33
hradilv.nospam is currently offline  hradilv.nospam
Messages: 19
Registered: November 2001
Junior Member
Any ideas on what would be the easiest (best?) way to split strings
that have the following characteristics? Perhaps best understood by
looking at examples?

1)
buf= '4 5 6'
strsplit(buf,' ',/extract) yields ['4','5','6'] {good}

2)
buf = '"4" "5" "6"'
strsplit(buf,'" "',/extract) yields ['4','5','6'] {good}

3)
buf='"" "5" "6"' {should get ['','5','6']}
strsplit,buf,'" "',/extract) yields ['5','6'] {misses the empty one}
strsplit,buf,'"',/extract) yields [' ','5',' ','6'] {adds an extra
empty one}

4)
buf='"3 4" "5" "6"' {should get ['3 4','5','6'}
strsplit(buf,'" "',/extract) yields ['3','4','5','6'] {adds an extra
one}
strsplit(buf,'"',/extract) yields ['3 4',' ','5',' ','6'] {I can
always then get rid of the ' ' elements}

Maybe I can summarize: I would like something that will split the
string by spaces, PROTECTED by "s. ie there may be spaces within the
"s which should not cause a split.

Thanks in advance

Vince
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Finding a structure in a structure
Next Topic: Getting checkbox value

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

Current Time: Wed Oct 08 14:55:43 PDT 2025

Total time taken to generate the page: 0.00515 seconds