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
 
V

Velislav

if the x's are numbers, something like this should do it:
Regex myRegex = new Regex(@"^\d{3}-\d{3}$");

if they're letters then try [a-zA-Z] instead of \d
 
P

pigeonrandle

Hi,
Not enough information ... are x's numbers or letters?

Letters: [A-Za-z][A-Za-z][A-Za-z]-[A-Za-z][A-Za-z][A-Za-z] would be one
way.

Have a look at this anyway...

http://www.regular-expressions.info/

it's very good and if you read the whole thing, you'd know more than
most!

HTH,
James Randle.
 

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

Similar Threads


Top