Regex Validator that matches null string

Topics: Validation Application Block
Jun 24, 2009 at 11:59 AM


I'm sorry if this isn't a 100% entlib question but I'm having problems creating a regexp for my regex validator.

My buisnessobject has a string property that either is null, or it has some contents that only can contain certain characters.

I've tried with: ^$|^[\w\s\.\-,':]*$

I've bolded the pipe-character to show that it's two different valid sets.

I can do it with a Or Composite Validator where I have a negated Not Null Validator and a Regex Validator, but I would like to only have to one validator so I can keep the number of validators down a little.

Jun 25, 2009 at 5:29 AM

As far as I know, null strings won't match anything.  But I'm not an expert on regular expressions so I suggest you post your question in some regular expressions forum like this


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.