utilitaire Posted July 26, 2005 Posted July 26, 2005 I have a question for you guys about a regular expression i want to build. I have a string that i want to test. I have my pattern that should be 1 to X times in my string. Thats works. But also, my customer can pass an empty value for this string. If my customer pass nothing, i want my regular expression to succeed also cause i accept empty value for certain textbox. I cant figure out how to manage an empty value in my string. Hope someone can give me a hint on that. Thanks in advance. Quote
mskeel Posted July 29, 2005 Posted July 29, 2005 will the "*" (0 or more) operator work for you? or perhaps "^0" ? You can try oring using the pipe | to say "Either my regex or nothing". I think the ^ operator is what you seek, though. Also, why not just do a check for empty string and then apply your regex? if (value == "" || Regex.Matches(...)) {... } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.