You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2003/03/06 01:48:52 UTC
[OT] need help in regex expression
Hi,
I have to validate a double field, which can be
negative or positive, has max 4 digits in integer and
max 2 digits after decimal,
I have the following regex which handles some cases
but need help to make it work in all casses
\b[\d]?[\d]?[\d]?[\d]?\b[\.,]?[\d]?[\d]?
it works in
1234.56
123.45
2334
0.34
but does not work
.34
and also i want it work for
-123.45
+234.45
Can any one suggest a way to modify expression or
write it in better way
Ashish
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [OT] need help in regex expression
Posted by alexj <al...@freesurf.ch>.
rhoo 2 max decimal
[+-][0-9]{0-9}("."2{0-9})
----- Original Message -----
From: "alexj" <al...@freesurf.ch>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, March 06, 2003 1:59 AM
Subject: Re: [OT] need help in regex expression
> ----- Original Message -----
> From: "Ashish Kulkarni" <ku...@yahoo.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, March 06, 2003 1:48 AM
> Subject: [OT] need help in regex expression
>
>
> > Hi,
> >
> > I have to validate a double field, which can be
> > negative or positive, has max 4 digits in integer and
> > max 2 digits after decimal,
> > I have the following regex which handles some cases
> > but need help to make it work in all casses
> >
> > \b[\d]?[\d]?[\d]?[\d]?\b[\.,]?[\d]?[\d]?
> > it works in
> > 1234.56
> > 123.45
> > 2334
> > 0.34
> > but does not work
> > .34
> >
> > and also i want it work for
> > -123.45
> > +234.45
> >
> > Can any one suggest a way to modify expression or
> > write it in better way
> >
> > Ashish
> >
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, more
> > http://taxes.yahoo.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [OT] need help in regex expression
Posted by alexj <al...@freesurf.ch>.
[+-][0-9]{0-9}("."{0-9})----- Original Message -----
From: "Ashish Kulkarni" <ku...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, March 06, 2003 1:48 AM
Subject: [OT] need help in regex expression
> Hi,
>
> I have to validate a double field, which can be
> negative or positive, has max 4 digits in integer and
> max 2 digits after decimal,
> I have the following regex which handles some cases
> but need help to make it work in all casses
>
> \b[\d]?[\d]?[\d]?[\d]?\b[\.,]?[\d]?[\d]?
> it works in
> 1234.56
> 123.45
> 2334
> 0.34
> but does not work
> .34
>
> and also i want it work for
> -123.45
> +234.45
>
> Can any one suggest a way to modify expression or
> write it in better way
>
> Ashish
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [OT] need help in regex expression
Posted by Jeff Kyser <kt...@comcast.net>.
try something like: ^([+-])?(\d){0,4}(.(\d){0,2})?$
-jeff
On Wednesday, March 5, 2003, at 06:48 PM, Ashish Kulkarni wrote:
> Hi,
>
> I have to validate a double field, which can be
> negative or positive, has max 4 digits in integer and
> max 2 digits after decimal,
> I have the following regex which handles some cases
> but need help to make it work in all casses
>
> \b[\d]?[\d]?[\d]?[\d]?\b[\.,]?[\d]?[\d]?
> it works in
> 1234.56
> 123.45
> 2334
> 0.34
> but does not work
> .34
>
> and also i want it work for
> -123.45
> +234.45
>
> Can any one suggest a way to modify expression or
> write it in better way
>
> Ashish
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org