RegularExpressionValidator question

F

Frank Rizzo

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.
 
P

Phil H

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.

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.
 
R

Riki

Frank said:
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.
 
H

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
 
J

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top