Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2006, 09:41 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default Urgent Help with regex

Hi Friends

Just wanted an urgent help, I want a C# regular expression to validate valid number but without decimals, plz help urgently

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
__________________
Regards
Mike
 
Old November 3rd, 2006, 09:45 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

How many decimal places? Infinite?

If you are trying to check valid currency, e.g. 2 decimal places then this will work:
[0-9]+(\.[0-9][0-9])

If you want any amount of decimal places
[0-9]+(\.\d)

I should probably note that the first regex works flawlessly in a RegularExpressionValidator it matches just X.XX but, for some reason, if I try to Match in code, it doesnt work as well, I dont know why. In any case those should work.

that should work

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old November 3rd, 2006, 10:00 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanx for the reply parsons

I want the number should only be a whole number without any decimals, no decimals should be allowed, only positive whole numbers

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old November 3rd, 2006, 10:07 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Then you just need the \d switch you might have to do \d+ but in either case it should work for you.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old November 3rd, 2006, 10:10 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanx parsons for your help

It worked out! however we can also simply use "[^0-9]", you know a bit work pressure to complete quickly, so mind goes..........

Anyways thanx for your help.

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent: RegEx to read a Text File jeusdi .NET Framework 1.x 1 February 8th, 2007 11:42 AM
Regex htran XSLT 2 May 18th, 2005 09:21 AM
More regex help Snib Pro PHP 4 December 16th, 2004 09:56 PM
Need RegEx help Snib Pro PHP 6 November 16th, 2004 06:59 AM
Regex Help boyer99g General .NET 2 October 8th, 2004 05:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.