Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Regular Expression Help
Message
De
09/03/2009 09:30:03
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
09/03/2009 09:07:12
Information générale
Forum:
Windows
Catégorie:
Informatique en général
Divers
Thread ID:
01386592
Message ID:
01386604
Vues:
24
>>I found the following RegEx string to validate a zip code: "^\d{5}(-\d{4})?$"
>>
>>The following two string pass the test: 90210, 90210-1234. However, I need to make it accept the following string: 90210-.
>>
>>Any help would be greatly appreciated. From the little I know about regular expressions, I think there needs to be another optional clause added. Thanks!!!
>>
>>Edit:
>>I changed it to the following and it seems to work: "^\d{5}(-)?(-\d{4})?$". Can somebody validate that I didn't do something silly? Thanks!
>
>Yours will accept 12345--1234
>
>^((\d{5}-?)|(\d{5}-\d{4})$
>
>or
>
>^\d{5}((-?)|(-\d{4})?)$
>
>
Thank you!
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform