in reply to Zipcode Regex Help
How about something like this?
The \b are to avoid accidentally matching an invalid zipcode likesub zipMatch { my $zip_card = shift; return 0 unless $zip_card =~ m/\b(\d{5})(?:-(\d{4}))?/b/; return 1 unless $2; return 2; }
0000000000-0000000000
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Zipcode Regex Help
by tcf22 (Priest) on Jun 25, 2003 at 21:31 UTC | |
by Abigail-II (Bishop) on Jun 26, 2003 at 01:39 UTC |