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

Home » Public Forums » archive » Re: Testing validity of numerical content of a string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Testing validity of numerical content of a string [message #51742] Wed, 06 December 2006 17:49 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
On Dec 6, 6:38 pm, David Fanning <n...@dfanning.com> wrote:
> Y.T. writes:
>> Maybe this is a stupid question, but is there a way in IDL to tell
>> whether a string contains a valid representation of a particular data
>> type? For example an integer? I can do something like
>

One "unixy" way to do this is with regular expressions. I end up using
these all the time (any should more).

Play with something like:
IDL> a='hello'
IDL> print, stregex(a, '[a-zA-Z]', /boolean)
1
IDL> b='3.14159'
IDL> print, stregex(b, '[a-zA-Z]', /boolean)
0
And one could work out a better regexp that looked for other
non-numeric chars as well.

This is good and easy.

Cheers,
Brian
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Adjacent plot question
Next Topic: Logarithmic Binning with Histogram function?

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

Current Time: Wed Oct 08 15:54:13 PDT 2025

Total time taken to generate the page: 0.00437 seconds