Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: RegEx
I need a regular expression that checks a numeric value to ensure it has two decimal places after the ".".
 
eg. 0.01, 0.10 is OK, but 2.0 or 0.1 is not OK.
 
It's for use with currency. However, I don't need to worry about the $ sign.
Posted 2-Feb-12 7:57am
Edited 2-Feb-12 8:23am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this:
 
/\d*\.\d{2}/
 
I rephrased your question so I hope this is what you were after/
  Permalink  
Comments
cutexxbaby at 2-Feb-12 13:32pm
   
but i try the expression you give, however , it give me dont allow me 0.01, 0.10 is which i want it to be OK

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



Advertise | Privacy | Mobile
Web01 | 2.8.150302.1 | Last Updated 2 Feb 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100