regular expression

J

JJ

I need the data passed in from the textbox to be in a certain format, eg
xxx-xxx or empty string. What is the regular expression syntax for that?
Thanks
 
A

Anthony Jones

JJ said:
I need the data passed in from the textbox to be in a certain format, eg
xxx-xxx or empty string. What is the regular expression syntax for that?
Thanks

It would help if you specified what domain of values is represented by x.
Any word character would be:-

^\w{3}-\w{3}$
 
J

JJ

Your string does not cover empty string. How do i make the regular
expression so that when the user types text into the textbox, then it should
follow ^\w{3}-\w{3}$ but also allows empty string?

Thanks
 
P

Peter Bradley

^(\w{3}-\w{3})*$

I would think.


Peter

JJ said:
Your string does not cover empty string. How do i make the regular
expression so that when the user types text into the textbox, then it
should follow ^\w{3}-\w{3}$ but also allows empty string?

Thanks
 
H

Hans Kesting

Your string does not cover empty string. How do i make the regular
expression so that when the user types text into the textbox, then it should
follow ^\w{3}-\w{3}$ but also allows empty string?

a RegularExpressionValidator will only check non-empty fields. An empty
field always satisfies all the validators, with one obvious exception:
the RequiredFieldValidator.
So you don't have to add code for the "empty" situation, it's the other
way around: if you *don't* want to accept an empty field, add a
RequiredFieldValidator.

Hans Kesting
 

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,780
Messages
2,569,608
Members
45,248
Latest member
MagdalenaB

Latest Threads

Top