Re: Character strings

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Thu, 9 Jul 2009 10:55:56 -0600

James,

If you can update to 5.1.1,
then you can use str_right_strip(str) to strip off any white-space at
right.
Or. str_left_strip to strip left end white space, or str_strip to
strip off
white space at both end.

For example, with 5.1,1,

you have
str1 = "abc "

str2 = str_ritgh_strip(str1)
and str2 will be "abc".

ncl 7> str1 = "abc "
ncl 8> print("<" + str1 + ">")
(0) <abc >
ncl 9> str2 = str_right_strip(str1)
ncl 10> print("<" + str2 + ">")
(0) <abc>

Wei Huang
huangwei_at_ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Jul 9, 2009, at 10:44 AM, Correia, James wrote:

> Is there a function which can trim white space out of a character
> string?
>
> For example I am reading in a file with model abbreviations and
> ensemble
> numbers like this:
> aom_1
> cgcm31t47_1
>
> Then using the names to construct a file name.
>
> However I am using asciiread to read the data string back into ncl
> and then
> use the array to open a new file. The above model names are read in
> using 10
> ascii elements to accommodate the whole list.
>
> So the file name ends up looking like:
> aom_1 _y8.dat
> Rather than
> aom_1_y8.dat
>
> So can the character string be trimmed down to non white space
> characters?
>
> I am using ncl v5.1.0
>
> jimmyc
>
>
> James Correia Jr., PhD
> Climate Physics Group
> Post. Doc.
> Pacific Northwest National Lab
>
> "Wisdom. Strength. Courage. Generosity. Each of us are born with one
> of
> these. It is up to us to find the other three inside of us."
> -Into the West
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 09 2009 - 10:55:56 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 13 2009 - 20:56:19 MDT