regular expression

  • Thread starter Thread starter JJ
  • Start date Start date
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
 
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
 
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.
 
Back
Top