By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,983 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,983 IT Pros & Developers. It's quick & easy.

RegExp question

P: n/a
Hello!

I have a following RegExp ^\d{5}?$
It should accept strings containing excatly fice numbers or an empty
string...
but it does not. Can anyone see whats wrong?

Code snippet checking this is below
// Sentence contains ^\d{5}?$

Regex RegExp = new Regex(Sentence, RegexOptions.IgnoreCase);
if(RegExp.Match(val).Success == false)
{
string text = "Validating Exception";
string keyAndValue = String.Format(" Key {0} with value {1} is
incorrect.", key, val);
throw new Exception(text + keyAndValue);
}
Cheers

Apr 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Hulk wrote:
Hello!

I have a following RegExp ^\d{5}?$
It should accept strings containing excatly fice numbers or an empty
string...
but it does not.
For those following along: this regex does not match an empty string
Can anyone see whats wrong?


^(\d{5})?$

--
Larry Lard
Replies to group please

Apr 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.