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 6:57am
Edited 2-Feb-12 7: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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 695
1 OriginalGriff 518
2 Abhinav S 313
3 thatraja 245
4 CPallini 130
0 Sergey Alexandrovich Kryukov 8,372
1 OriginalGriff 4,830
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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