regular expression

  • Thread starter Thread starter JJ
  • Start date Start date
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
 
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
 
Back
Top