Re: Removing the blanks between elements in a string array [message #69711] |
Fri, 29 January 2010 20:53 |
sulli.jj
Messages: 3 Registered: July 2009
|
Junior Member |
|
|
On Jan 29, 9:46 pm, pp <pp.pente...@gmail.com> wrote:
> On Jan 30, 2:31 am, "sulli.jj" <sulli...@gmail.com> wrote:
>
>
>
>
>
>> Does anyone know a easy to way to print out an array with no blanks at
>> all?
>
>> I have an array of strings like
>> a = [[' cat,','d o g,','bi rd ' ],[' 1.23, ',' 4. 56,','
>> 7.89 ']]
>
>> print, a
>> cat, d o g, bi rd
>> 1.23, 4. 56, 7.89
>
>> I can remove most of the spaces with,
>
>> print, STRCOMPRESS(a, /REMOVE_ALL)
>> cat, dog, bird
>> 1.23, 4.56, 7.89
>
> There are no blanks in the array from strcompress with remove_all. The
> spaces between elements are put there by print's default format.
>
> Two ways to get what you want are
>
> print,strcompress(a,/remove_all),format='(3A0)'
>
> print,strjoin(strcompress(a,/remove_all)),format='(A0)'- Hide quoted text -
>
> - Show quoted text -
Ah, that makes more sense. Thanks for your help!
|
|
|
Re: Removing the blanks between elements in a string array [message #69712 is a reply to message #69711] |
Fri, 29 January 2010 20:46  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Jan 30, 2:31 am, "sulli.jj" <sulli...@gmail.com> wrote:
> Does anyone know a easy to way to print out an array with no blanks at
> all?
>
> I have an array of strings like
> a = [[' cat,','d o g,','bi rd ' ],[' 1.23, ',' 4. 56,','
> 7.89 ']]
>
> print, a
> cat, d o g, bi rd
> 1.23, 4. 56, 7.89
>
> I can remove most of the spaces with,
>
> print, STRCOMPRESS(a, /REMOVE_ALL)
> cat, dog, bird
> 1.23, 4.56, 7.89
>
There are no blanks in the array from strcompress with remove_all. The
spaces between elements are put there by print's default format.
Two ways to get what you want are
print,strcompress(a,/remove_all),format='(3A0)'
print,strjoin(strcompress(a,/remove_all)),format='(A0)'
|
|
|