regularexpressionvalidator "does not contain"

by Kyle Morris on 11/1/2007 8:10:00 AM so the challenge is how to create a regex that validates a control when it
doesnt contain particular words or phrases. I've used the validator plenty
of times to validate correct input in different formats but never like this
before.

the example I would give would be how to stop a filename field using a
particular file extension say .asp, .php, aspx, etc

I know how to validate so that it does contain it, but not how to validate
so that it doesnt contain it.

any help would be greatly appreciated.

Cheers!
Kyle


 

Re: regularexpressionvalidator "does not contain"

by Jesse Houwing on 11/1/2007 10:30:00 PM Hello Kyle,

> so the challenge is how to create a regex that validates a control
> when it doesnt contain particular words or phrases. I've used the
> validator plenty of times to validate correct input in different
> formats but never like this before.
>
> the example I would give would be how to stop a filename field using a
> particular file extension say .asp, .php, aspx, etc
>
> I know how to validate so that it does contain it, but not how to
> validate so that it doesnt contain it.
>
> any help would be greatly appreciated.

Regex isn't the tool to use here. You're much better off with a customvalidator
with a javascript function and a serverside function or your own implementation
of IValidatorControl.

If you're willing to forego clientside validation you could use the following
expression (which isn't supported in javascript as far as I know)

^(?!(the|words|you|don't|like).)*$

Or if it's just the extention you're after:

^.*(?<!the|extentions|you|won't|allow)$

--
Jesse Houwing
jesse.houwing at sogeti.nl