[ncl-talk] Is string numeric?
Carl Schreck
cjschrec at ncsu.edu
Tue Mar 22 09:34:26 MDT 2016
Turns out it wasn't too hard to make a quick and dirty function for this.
It will miss some things, but probably good enough.
Thanks!
Carl
On Mon, Mar 21, 2016 at 2:09 PM, Carl Schreck <cjschrec at ncsu.edu> wrote:
> Is there a function that would tell me if a string is a numeric? i.e.,
> contains no letters and "tofloat" won't give a warning on it?
>
> If not, has anyone already made one? Thanks!
>
> e.g.:
> str_is_numeric( "215" ) => True
> str_is_numeric( "21.5" ) => True
> str_is_numeric( "21e5" ) => True
> str_is_numeric( "21N5" ) => False
>
> Carl
>
> --
>
> <http://www.cicsnc.org/>
> <http://www.researcherid.com/rid/B-8711-2011>
> * Cyclone <http://www.cyclonecenter.org/>*Center.org
> <http://www.cyclonecenter.org/> *Carl J. Schreck III, PhD*
> *Research Scholar / Research **Assistant Professor*
> Cooperative Institute for Climate and Satellites NC (CICS
> <http://www.cicsnc.org/>*-NC) <http://www.cicsnc.org/> /*
> Department of Marine, Earth, and Atmospheric Sciences (MEAS)
> <https://meas.sciences.ncsu.edu/>
> North Carolina State University <http://ncsu.edu/>
> NOAA National Centers for Environmental Information (NCEI)
> <http://ncei.noaa.gov/>
> 151 Patton Ave, Asheville, NC 28801
> e: carl_schreck at ncsu.edu
> o: +1 828 257 3140
> c: +1 828 484 1702
> Publications
> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
> monitor.cicsnc.org/mjo
>
--
<http://www.cicsnc.org/>
<http://www.researcherid.com/rid/B-8711-2011>
* Cyclone <http://www.cyclonecenter.org/>*Center.org
<http://www.cyclonecenter.org/> *Carl J. Schreck III, PhD*
*Research Scholar / Research **Assistant Professor*
Cooperative Institute for Climate and Satellites NC (CICS
<http://www.cicsnc.org/>*-NC) <http://www.cicsnc.org/> /*
Department of Marine, Earth, and Atmospheric Sciences (MEAS)
<https://meas.sciences.ncsu.edu/>
North Carolina State University <http://ncsu.edu/>
NOAA National Centers for Environmental Information (NCEI)
<http://ncei.noaa.gov/>
151 Patton Ave, Asheville, NC 28801
e: carl_schreck at ncsu.edu
o: +1 828 257 3140
c: +1 828 484 1702
Publications
<http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
monitor.cicsnc.org/mjo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160322/d4ed2864/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: is_string_numeric.ncl
Type: application/octet-stream
Size: 749 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160322/d4ed2864/attachment.obj
More information about the ncl-talk
mailing list