RegularExpressionValidator question

RegularExpressionValidator question

am 29.12.2007 21:23:52 von Rudiga

Hello,

Trying to setup RegularExpressionValidator to validate a textbox. I am
trying to make sure that the user enters the word Green. The case does
not matter.

However, i am totally new to Regex. Could I get some help?

Thanks.

Re: RegularExpressionValidator question

am 30.12.2007 00:06:08 von Phil H

On 29 Dec, 20:23, Frank Rizzo wrote:
> Hello,
>
> Trying to setup RegularExpressionValidator to validate a textbox. =A0I am
> trying to make sure that the user enters the word Green. =A0The case does
> not matter.
>
> However, i am totally new to Regex. =A0Could I get some help?
>
> Thanks.

Hi Frank

It just so happens that I too have been delving into the undergound
world of "Regular expressions" recently. My need was a bit more
complex than yours though.

I'm going to assume at this point that if you were given a patterrn
string you can do the rest. How about:

"(green)+"

when you create the Regex object there is a parameter that specifies
"ignore case". Check it out.

To decide whether it occurs or not you only need to test the "success"
property of the "match" object.

I hope I've pitched the above at the right level, let me know
otherwise.

Re: RegularExpressionValidator question

am 30.12.2007 09:26:09 von Riki

Frank Rizzo wrote:
> Hello,
>
> Trying to setup RegularExpressionValidator to validate a textbox. I
> am trying to make sure that the user enters the word Green. The case
> does not matter.
>
> However, i am totally new to Regex. Could I get some help?
>
> Thanks.

Try ^(green)|(Green)|(GREEN)$

Don't forget to add a RequiredFieldValidator as well.
If you don't, a blank field will still be validated.

--
Riki

Re: RegularExpressionValidator question

am 04.01.2008 16:50:09 von Hans Kesting

Frank Rizzo explained :
> Hello,
>
> Trying to setup RegularExpressionValidator to validate a textbox. I am
> trying to make sure that the user enters the word Green. The case does not
> matter.
>
> However, i am totally new to Regex. Could I get some help?
>
> Thanks.

Just a word of warning:
The validator uses client-side javascript by default, and the js-syntax
for regexes is a subset of the syntax in .Net. So be careful when you
use some regex that works in .Net in a validator.
For the main part it's the "advanced features" that are missing in js.
But in your case a "ignore case" option *is* an advanced feature.

Hans Kesting

Re: RegularExpressionValidator question

am 07.01.2008 23:06:26 von Jesse Houwing

Hello Frank,

> Hello,
>
> Trying to setup RegularExpressionValidator to validate a textbox. I
> am trying to make sure that the user enters the word Green. The case
> does not matter.
>
> However, i am totally new to Regex. Could I get some help?
>
> Thanks.
>

As the patterns of the regex validator are case sensitive by default and
given that there is no way to inline a case insensitivity marker, you'll
have to do the following:

^[gG][rR][eE][eE][nN]$

or (just a little shorter):

^[gG][rR][eE]{2}[nN]$

Jesse

--
Jesse Houwing
jesse.houwing at sogeti.nl