SageFix. LetsFix!  
Current Location : Home > Web Development > JavaScript > Regex help > Post Share/Save/Bookmark    

Main Menu
SageFix - Let's Fix

Board Categories
    Web Site Designing
- Graphics
    Web Development
- .NET
- Classic ASP
- JavaScript
- PHP
    WebSite Management
- Promotion Techniques
- Search Engine Optimization
    Databases
- MySQL

Tutorials

Database Connection Strings

  Contact Us


Regex help      Jul 23, 2002, 11:08 990469
  
I'm making a regex to validate money data, and these are the rules I want: (X will represent numbers)

$ must be at front
.XX -OR- .X is optional for end
. at end NOT valid
1-3 digits left of decimal
infite combinations of XXX, where needed

Examples of valid formats
$xx,xxx.xx
$xxx,xxx,xxx,xxx
$x,xxx,xxx.x
$x.xx

Examples of invalid formats:
$xxxxx
xx,xxx.xx
$xx,xxx.
$xxx,xxx.xxx

Here is what I've got so far, but I know it doesn't work...
Code:
moneyReg = "^//$([0-9]{1,3}[,]{1})*([0-9]{1-3})+(//.[0-9]{1,2})?$";
I've had several iterations that have had some success, but not total. This is where I am now, and it breaks pretty much on everything...my brain is too tired to backtrack.

Thanks in advance!

 









Subscribe to our mailing list
email


Current Location : Home > Web Development > JavaScript > Regex help > Post Share/Save/Bookmark    

Development problem? SageFix is completely free -- paid for by advertisers and donations. Click here to Contact Us If you have any query. Enjoy!
Request processed in 7.0E-5 seconds Home - Contact Us - Terms Of Service - Privacy Policy - Copyrights - Top
Advertisements do not imply our endorsement of that product or service.
Current server time now is 09-Sep-2010 09:59:18
Copyright © 2009 Sagefix Inc. All rights reserved.
Powered By SageFix