regular expression

J

JJ

I need the data passed in from the textbox to be either ^([0-9]{1,5}\s)+ or
empty string.
How do i incorporate empty string requirement into the regular expression?
Thanks
 
E

Ethan Strauss

I would check it just that way you have written.
That is:
if (TextBox.Text.Length == 0 || Regex.IsMatch(TextBox.Text,
"^([0-9]{1,5}\s)+"))
{
DoWhatYouNeed;
}

I don't know offhand how to get the Regex to do the match. I would guess
(.{0}|^([0-9]{1,5}\s)+ ), but I have not tested it...
Ethan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top