[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to check if a field is a number (integer or float)?

From: Peng Yu
Subject: Re: How to check if a field is a number (integer or float)?
Date: Sat, 19 Jun 2021 10:35:48 -0500

The best solution that I figured out is just `typeof(x) == "strnum"`||
typeof(x) == "number"` instead of using regex.

However, I see many wrong answers. For example, the following seems to
be wrong in corner cases.


Please let me know the way to test something can be interpreted as a
number with 100% accuracy. Thanks.

On 6/19/21, Peng Yu <pengyu.ut@gmail.com> wrote:
> Hi,
> I am wondering what is the best way to test if a field is a number
> (integer of float). I could use regex. But I am wondering if there is
> a more awk-native way to do the test. Also if regex is used, what is
> the regex that matches integer/float used awk. Thanks.
> --
> Regards,
> Peng


reply via email to

[Prev in Thread] Current Thread [Next in Thread]