RE: Validating Decimal Values
- From: hridyesh.pant@xxxxxxxxxxxxxx (Hridyesh Pant)
- Date: Thu, 1 Dec 2005 02:32:48 -0500
Try this
if ($a=~/^\d{0,5}\.\d{0,2}$/)
Regards
Hridyesh
-----Original Message-----
From: Joel Divekar [mailto:joel_divekar@xxxxxxxxx]
Sent: 01 December 2005 12:52
To: beginners@xxxxxxxx
Subject: Validating Decimal Values
Hi
I am having a small program which parses data file.
The data file contains decimal values and I am not
able to validate the decimal number.
For eg. the decimal number will be as follows
Max Size : 99999.99
valid values : 3.00 or 745.15 or 21576.00
invalid values : 3.001 or 745.1555 or 215766.00
also 3..00 should be marked invalid.
I am not good with RE but I tried following code, but
I am not sure if I am in right direction. Can anybody
help or guide me ?
***********************************
my $a = "3.89011";
if ($a=~/^\d{0,5}\.\d{0,2}/)
{
print "Valid";
}
else
{
print "Invalid";
}
***********************************
or is there any perl module available to do validation
of alpha, numeric and alphanumeric (with decimal) data
type ?
Thanks
Regards
Joel
Mumbai, India
9821421965
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>
.
- Prev by Date: Validating Decimal Values
- Next by Date: Re: Validating Decimal Values
- Previous by thread: Re: Validating Decimal Values
- Next by thread: search in a website
- Index(es):
Relevant Pages
|