Search:
Namespaces
Discussions
.NET v1.1
Feedback
How to match a range of numbers?
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngregexp' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Oskar Sandwall
What I want to do is to match integers between 0 to 3567.
I have problem doing this since i only know how to match
numbers between 0 and 9999 "^[0-9]{1,4}".
Can anyone help me... or tell me its impossible? :)
Thank you!
................................................................
SVERIGES ENKLASTE E-POSTADRESS! -
http://www.sverige.nu
SVERIGES NYA ADRESSREGISTER! - http://www.adress.nu
Reply to this message...
Scott (VIP)
The only way I know how to do it is to make essentially several matches.
Something like : (this is off the top of my head, but it should be
close)
([0-2][0-9]{0,3})|(3[0-4][0-9][0-9])|(35[0-5][0-9])|(356[0-7])
The first part matches everything from 0 to 2999. The second part
matches everything from 3000 - 3499, part 3 matches 3500 - 3559, the
last part matches 3560 - 3569.
Scott Swigart
3 Leaf Solutions, LLC
www.3leaf.com
503-281-9681
-----Original Message-----
From: Oskar Sandwall [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, November 01, 2001 7:15 AM
To: aspngregexp
Subject: [aspngregexp] How to match a range of numbers?
What I want to do is to match integers between 0 to 3567.
I have problem doing this since i only know how to match numbers between
0 and 9999 "^[0-9]{1,4}".
Can anyone help me... or tell me its impossible? :)
Thank you!
................................................................
SVERIGES ENKLASTE E-POSTADRESS! -
http://www.sverige.nu=20
SVERIGES NYA ADRESSREGISTER! -
http://www.adress.nu
| [aspngregexp] member
Click here to reveal e-mail address
=3D YOUR ID=20
|
http://www.asplists.com/asplists/aspngregexp.asp
=3D JOIN/QUIT=20
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
Benjamin D. Gray
Something like this might work for you:
"(3[0-4][0-9]{2})|(35[0-5][0-9])|(356[0-7])|([1-2][0-9]{3})|([0-9]{1,3})
"
bdgray
-----Original Message-----
From: Oskar Sandwall [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, November 01, 2001 8:15 AM
To: aspngregexp
Subject: [aspngregexp] How to match a range of numbers?
What I want to do is to match integers between 0 to 3567.
I have problem doing this since i only know how to match
numbers between 0 and 9999 "^[0-9]{1,4}".
Can anyone help me... or tell me its impossible? :)
Thank you!
................................................................
SVERIGES ENKLASTE E-POSTADRESS! -
http://www.sverige.nu=20
SVERIGES NYA ADRESSREGISTER! -
http://www.adress.nu
| [aspngregexp] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngregexp.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
Wayne King
Here's a slightly different pattern along the same lines (spaces added =
to expression for clarity):
^( \d{1,3} | [0-2]\d{3} | 3[0-4]\d{2} | 35[0-5]\d | 356[0-7] )$
You could reduce this expression down a few different ways to make it a =
little more efficient. One obvious way is:
^( \d{1,3} | [0-2]\d{3} |
3 ([0-4]\d{2} |=20
5 ([0-5]\d | 6[0-7] )
)
)$
When you use the expression, use the
RegexOptions
.ExplicitCapture =
option, and if you leave the whitespace or newlines include =
RegexOptions
.IgnorePatternWhitespace.
-----Original Message-----
From: Scott [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, November 01, 2001 8:16 AM
To: aspngregexp
Subject: [aspngregexp] RE: How to match a range of numbers?
The only way I know how to do it is to make essentially several matches.
Something like : (this is off the top of my head, but it should be
close)
([0-2][0-9]{0,3})|(3[0-4][0-9][0-9])|(35[0-5][0-9])|(356[0-7])
The first part matches everything from 0 to 2999. The second part
matches everything from 3000 - 3499, part 3 matches 3500 - 3559, the
last part matches 3560 - 3569.
Scott Swigart
3 Leaf Solutions, LLC
www.3leaf.com
503-281-9681
-----Original Message-----
From: Oskar Sandwall [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, November 01, 2001 7:15 AM
To: aspngregexp
Subject: [aspngregexp] How to match a range of numbers?
What I want to do is to match integers between 0 to 3567.
I have problem doing this since i only know how to match numbers between
0 and 9999 "^[0-9]{1,4}".
Can anyone help me... or tell me its impossible? :)
Thank you!
................................................................
SVERIGES ENKLASTE E-POSTADRESS! -
http://www.sverige.nu=20
SVERIGES NYA ADRESSREGISTER! -
http://www.adress.nu
| [aspngregexp] member
Click here to reveal e-mail address
=3D YOUR ID=20
|
http://www.asplists.com/asplists/aspngregexp.asp
=3D JOIN/QUIT=20
|
http://www.asplists.com/search
=3D SEARCH Archives
| [aspngregexp] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngregexp.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
System.Text.RegularExpressions.RegexOptions
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com