web regularexpression not working in windows

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Standar 9-digit postal code expression, copied and pasted from a web
form validator expression:

@"\d{5}(-\d{4})?

I try to use it to validate a windows textbox, but it does not like
the '?'.
If the first part is matched,it doesnt care what comes afterwards.
Removing the ? gives proper behavior.

Can anyone please tell me why this is works on an asp page but not
with the Regex class?

Thanks,
Greg
 
(e-mail address removed) (Greg) wrote in
Standar 9-digit postal code expression, copied and pasted from a
web form validator expression:

@"\d{5}(-\d{4})?

I try to use it to validate a windows textbox, but it does not
like the '?'.
If the first part is matched,it doesnt care what comes
afterwards. Removing the ? gives proper behavior.

Can anyone please tell me why this is works on an asp page but
not with the Regex class?

Greg,

It may just be a typo, but are you sure the leading @" is part of the
regex? I tested the regex \d{5}(-\d{4})? on my system and it worked
fine.

Chris.
 
Thanks Chris,

Actually found out today that I needed the $ to mark the end of the
string even though i knew the length. I just cut and paste the
expression from the asp regularexpressionvalidator combo, but the ^ and
$ must be prepended to those expressions.

Thanks for your help

Greg
 
Back
Top