Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2003, 12:26 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default .NET Regular Expressions

I'm having two little problems with my first attempt at regular expressions - I would like the following to determine whether user input is a certain type of numeric: 7 digits possibly followed by a decimal point and possibly 2 post decimal digits:
 "^[0-9]{0,7}\.?[0-9]{0,2}$"

1. How do I specify that the 2 digits after the decimal are only appropriate if there indeed is a decimal? Currently, it allows a 9-digit number without a decimal.
2. Can I substitute variables for the 7 and 2? I tried and can't make it work - are there some special delimiters used to surround variables? e.g., I want to do something like:
 "^[0-9]{0,iPreDecimalDigits}\.?[0-9]{0,iPostDecimalDigits}$"

Thanks,
Dave Doknjas

Reply With Quote
  #2 (permalink)  
Old August 8th, 2003, 05:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

try the following :

/^(\d{7})|(\d{7}.\d{0,2))$/

This will allow either a 7 digit number or a 7 digit number, decimal point, and then 2 digits.
Reply With Quote
  #3 (permalink)  
Old August 8th, 2003, 07:10 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg!
I made a slight change to get it to work:
^(\d{0,7}|\d{0,7}\.\d{0,2})$


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Regular Expressions in ASP.NET/VB.NET toddw607 ASP.NET 1.0 and 1.1 Basics 0 February 5th, 2008 04:26 PM
Do I need regular expressions..? ypomonh XSLT 2 May 20th, 2007 05:09 PM
Help with Regular Expressions WestRowOps Other Programming Languages 1 May 18th, 2007 05:34 AM
Regular Expressions mega Beginning PHP 1 February 5th, 2007 05:31 PM
Regular expressions on C# hideway C# 2 November 27th, 2006 05:08 PM



All times are GMT -4. The time now is 08:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.