Re: Regex expression for numeric value with length check
- From: "Jialiang Ge [MSFT]" <jialge@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Oct 2008 15:03:18 +0800
Good morning Wdudek,
Based on the MSDN article mentioned by Bob, I write this regular expression
for your reference. It checks a string contains all numbers and is between
1~9 characters long.
\b([0-9]{1,9})\b
Please let us know whether it works for you or not.
Have a very nice day!
Regards,
Jialiang Ge (jialge@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within 2
business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
"eBob.com" <fakename@xxxxxxxxxxxxxxxx> wrote in message
news:uOy%23zTJOJHA.3876@xxxxxxxxxxxxxxxxxxxxxxx
I think that this is what you need:
http://msdn.microsoft.com/en-us/library/3206d374.aspx
Also, get a FREE product called Expresso from UltraPico.
Good Luck, Bob
"wdudek" <wdudek@xxxxxxxxxxxxxxxx> wrote in message
news:EE3DD8A1-CDB3-497B-BF78-64A6E53D0FF3@xxxxxxxxxxxxxxxx
Hi,
I am horrible at regular expressions so I'm hoping this might be an
easy
one for someone else. I need to perform a check that a string contains
all
numbers and is between 1 and 9 characters long. I have the first part
working, but can't get the length check to work.
This is what I am using to perform the check to see if the string is all
numeric. ^[0-9]*$
However I can't get it to match anything when I have tried to check the
length as well. Also I need to do this in one expression, i.e. I can't
make 1
call to check for numeric values and a second to check for length.
Thanks,
Bill
P.S. This is what I have been using to test this.
static void Main(string[] args)
{
//string input = "00767140001575333";
string input = "00767140";
Regex r = new Regex("^[0-9]*$");
bool result = r.IsMatch(input);
Console.WriteLine(result.ToString());
Console.WriteLine("hit a key");
Console.ReadKey();
}
.
- Follow-Ups:
- References:
- Regex expression for numeric value with length check
- From: wdudek
- Re: Regex expression for numeric value with length check
- From: eBob.com
- Regex expression for numeric value with length check
- Prev by Date: Re: Outlook changing email format
- Next by Date: Re: DataSource
- Previous by thread: Re: Regex expression for numeric value with length check
- Next by thread: Re: Regex expression for numeric value with length check
- Index(es):
Relevant Pages
|