Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Space after zip code

Status
Not open for further replies.

Jarrod13

Programmer
Dec 18, 2008
12
I'm trying to modify this regular expression so that a zip code with a space directly after it will pass. That is, if I have a zip code "45887 " It will not be added to the "BadZipCount array"

I've highlighted in blue what I have now. It will check for a space before and after the zip code and if there is one the "BadZipCount array" will be incremented.


Code:
if(ZIPCODE !~ "^[0-9][0-9][0-9][0-9][0-9]$" && ZIPCODE !~ "^([0-9][0-9][0-9][0-9][0-9])(-)([0-9][0-9][0-9][0-9])$" && ZIPCODE != "" && [COLOR=blue]ZIPCODE !~ "^[ \t]*$[/color]")
                        {
                                BadZipCount[x]++;
                                BadZipCounter++;
                                BadZipArray[BadZipCounter]=ZIPCODE;
                                ZipColumn[ZIPFIELDS[x]] = (BadZipCount[x] "," ZIPFIELDS[x]);
                        }

Thank you
 
What about this ?
Code:
if(ZIPCODE !~ "^[0-9]{5}[ \t]{0,1}$" && ZIPCODE !~ "^[0-9]{5}-[0-9]{4}[ \t]{0,1}$" && ZIPCODE !~ "^[ \t]*$")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top