On Thu, 18 Jan 2001 20:33:03 -0500, Ronald J Kimball wrote:

>I make no guarantee of the correctness of this regex:
>
>/^\s*[+-]?(?:\d+\.?\d*|\.?\d+)(?:[eE][+-]?\d+)?(?!\n)$/;

It looks almost right, apart from a few details.

First: you don't need the question mark after the decimal point in the
second alternative for the first group. Digits only is covered in the
first alternative.

But: why don't you like your numbers ending in a newline? Perl doesn't
complain if you do:

        $_ = "1\n";
        print 2+$_;

even with warnings enabled.

And trailing whitspace doesn't hurt, either.

        /^\s*[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?\s*/

-- 
        Bart.

Reply via email to