web regularexpression not working in windows

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
 
C

Chris R. Timmons

(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.
 
G

greg drohan

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
 

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

Top