.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 16th, 2004, 08:22 AM
k89mmk k89mmk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Newfoundland, Canada
Posts: 97 k89mmk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 15 sec
Reputation Power: 6
Custom Validation Regular Expression (money)

I'm using a Custom Validation Control in ASP.NET and am trying to write the regular expression to recognize money. The entry may or may not contain $, it may or may not contain comma's, it may or may not include the cents(.##), and it must have at least one digit. So this is what I came up with (I have no previous regular expression experience and it will probably show)

\$?[0-9]+(\,[0-9]{3}]*(\.[0-9]{2})?

I'm trying to say
0 or more $ followed by
1 or more digits from 0 to 9 followed by
0 or 1 comma's followed by three digits from 0 - 9 followed by
0 or 1 period's followed by two digits

Its not recognizing anything that I try .... Any help is greatly appreciated.

Thanks.

Reply With Quote
  #2  
Old January 16th, 2004, 10:57 AM
vndasc vndasc is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 9 vndasc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
guess this works

RegExp( /^\$?(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,2}){0,1}$/ );


try this
das

Reply With Quote
  #3  
Old January 16th, 2004, 11:29 AM
k89mmk k89mmk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Newfoundland, Canada
Posts: 97 k89mmk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 23 m 15 sec
Reputation Power: 6
Thanks. This worked too.

^\$?[0-9]+(,[0-9]{3})*(\.[0-9]{2})?$

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Custom Validation Regular Expression (money)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT