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 February 7th, 2004, 03:14 PM
Authorized User
 
Join Date: Jul 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default regular expression with numbers and blanks

Okay, I have a regular expression to check for a numeric data type that looks as (\d{1,}). Is there a way to incorporate into this expression to allow whitespaces in between the numbers?
 
Old February 11th, 2004, 09:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about [0-9 ]+ (i.e. replace the \d with 0-9 and then add a space character. Also, + is equivalent to {1,})
 
Old March 4th, 2004, 04:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You could also do (\d+\w+)+ which will check for a number (or group of numbers), then for whitespace, then repeats over and over again.
 
Old March 4th, 2004, 08:16 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but this does not accept 0.00 as numeric value or it does not accept "."(decimal point) as numeric value. What is the best solution? How can I write such regular expression

Bharat Gadhia
================
Oh - once in your life you find someone
Who will turn your world around
Bring you up when you're feelin' down

From: Bryan Adams
Heaven

Bharat Gadhia
 
Old March 5th, 2004, 09:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I don't know if the \d includes decimal points. It may, but I don't know. You'll have to check that out.

If decimal points need to be included (and the \d doesn't cover it), but also spaces are required between numbers, you could do:

(\d+(\.\d+)?\s+)+

I realize one error on my part previously; I used a \w instead of \s; \w doesn't contain spaces.

This allows for:
<many digits to the left>.<many digits to the right><many spaces>

For one space change \s+ to \s
For multiple decimal points (or possibly none) change (\.\d+)? to (\.\d+)*





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression balajinrs Visual Studio 2005 0 July 24th, 2008 02:11 AM
Regular expression for phone numbers [both U.S. an kamii47 BOOK: Beginning Regular Expressions 0 September 8th, 2007 03:08 AM
Regular Expression in C++ praveenholal C++ Programming 1 March 4th, 2007 01:18 AM
need regular expression keyvanjan ASP.NET 1.0 and 1.1 Basics 5 August 31st, 2006 07:16 AM
regular expression Moharo Pro PHP 3 April 30th, 2004 04:44 AM





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