[ncl-talk] Problem with str_match

Wei Huang huangwei at ucar.edu
Mon Mar 9 09:40:46 MDT 2015


Sophie,

In the earlier version, NCL used regex for string match, which is why it
worked there.
The current version, NCL has switched to character match, which is why it
failed there.

Here is a short code (based on your case) on how to use NCL str_match.

;NCL does not support regex string match/compare, the following code will
return missing.
 varname="rntcre"
 a=str_match(varname,"r[lsn][ats]cre")
 print (a)

;NCL supports plain character string match, the following code will return
the match.
 b=str_match(varname,"ntcre")
 print (b)
------------------------
Here is the print out from the code above.
-------------------------------
Variable: a
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
Number Of Attributes: 1
  _FillValue :  missing
(0)     missing


Variable: b
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
(0)     rntcre


Please let ncl-talk know if there is anything can help.

Wei


================================================
1850 Table Mesa Dr.
Boulder, CO 80307
Phone: 303-497-8924

On Mon, Mar 9, 2015 at 9:27 AM, TYTECA Sophie <sophie.tyteca at meteo.fr>
wrote:

> Hello,
>
> I have a problem with str_match function and the NCL last version .
> the result gives "missing" in my string
>
> Here my machine: Linux x86_64 GNU/Linux
>
> *ncl*
>  Copyright (C) 1995-2014 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language *Version 6.2.1*
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
> *ncl 0> varname="rntcre"*
> *ncl 1> a=str_match(varname,"r[lsn][ats]cre")*
> *ncl 2> print (a)*
>
> Variable: a
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [1]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :    missing
> (0)    missing
>
> this function works with NCL previous version:
>
> *ncl*
>  Copyright (C) 1995-2012 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language *Version 6.1.0*
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
> *ncl 0> varname="rntcre"*
> *ncl 1> a=str_match(varname,"r[lsn][ats]cre")*
> *ncl 2> print (a)*
>
> Variable: a
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [1]
> Coordinates:
> (0)    rntcre
>
> Could you help me, please?
> Thank you very much
>
> ----- Météo-France -----
> TYTECA SOPHIE
> CNRM/GMGEC/VDR
> sophie.tyteca at meteo.fr
> Fixe : +33 561079379
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150309/d32cf2d7/attachment.html 


More information about the ncl-talk mailing list