Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can anyone give regular expression to validate amount field.
So that i match that regex to my amount text field.

My regex should satisfy the below condition.

1) Number.Number (e.g 99.99)
2) Number. (e.g 99.)
3) .Number (e.g .99)
4) Number (e.g 9999)

***But it should not allow single dot (.)

I used the below regex to amount field in the designer:
@"^(([0-9]{0,9})(\.+)\d{0,2}|[0-9]{0,9})$"

I want the matching regex to satisfy the above conditions.

Thanks in advance.
Posted
Comments
StianSandberg 18-Jul-12 6:47am    
http://regexlib.com

The following regex works for me to satisfy all of the above conditions.

@"([^.\d]+|[\d+\.]{2,})"

Hogan
 
Share this answer
 
read this very good Article[^]
 
Share this answer
 
"^[0-9]*[.][0-9]*$"

#Only for numbers
#:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900