in reply to Re: integer validation
in thread integer validation

That allows the following input:
-54 54- 5-4
I try to specify exactly what is valid:
/^-?\d+$/
Update: Yup, Kanji is right (note the lowercase z). I never had that problem because I chomp my input first.

--isotope
http://www.skylab.org/~isotope/

Replies are listed 'Best First'.
Re: Re: Re: integer validation
by Kanji (Parson) on Apr 28, 2001 at 03:33 UTC
    I try to specify exactly what is valid:

    Then wouldn't you want /\A-?\d+\z/?

    If it's there, $ will match a single newline at the end of your string, and you'd end up matching something bogus like "7\n".

        --k.


Re: Re: Re: integer validation
by Trinary (Pilgrim) on Apr 28, 2001 at 02:11 UTC
    Jeez. Of course you're right.

    Something about quarter past 4 on a warm friday afternoon seems to have made thinking difficult.

    Trinary