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
In reply to Re: Zipcode Regex Help
by dws
in thread Zipcode Regex Help
by tcf22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |