[VPM] detecting non-integers

abez abez at abez.ca
Mon May 5 18:12:10 CDT 2003


\d+(\.)*

means any integer even if there is no period.

I think what you might want is

/^(\-){0,1}\d+$/ #is an integer then you can negate this if you want.

/^(\-){0,1}\d+\.\d+$/ #is a float

abram

On Mon, 5 May 2003, Carl B. Constantine wrote:

> I have a web CGI that I'm modifying. I want to make it so that you can
> only input an integer number. So if anyone tries to type 10.44, it is
> detected by my CGI and refused.
>
> Since perl doesn't have types as such, what is the best way to detect
> this, just a regex like: =~/\d+(\.)*/ or is there an easier way?
>
>
>

-- 
abez ------------------------------------------
http://www.abez.ca/ Abram Hindle (abez at abez.ca)
------------------------------------------ abez



More information about the Victoria-pm mailing list