[Chicago-talk] Help with Regex
Richard Reina
richard at rushlogistics.com
Sat Dec 24 07:59:14 PST 2022
Happy Holidays Perl Family,
I am trying to use the regex below to find City, ST. Zip in a file. While the below does work for instances like Chicago, IL 60614 or Dallas, TX 75234,
it does not work in instances with multi word cities like Salt Lake City, UT 89159 or in instances with nine digit zip codes like Tampa, FL 33592-2787.
Any help in getting my regex to work would be greatly appreciated.
if ($row =~ /^([^,]+),\s([A-Z]{2})(?:\s(\d{5}-?\d{4}?))?$/) {
print "I think I found a city state zip:\n";
print "$row\n";
chomp (my $ff=<STDIN>);
}
Thanks all, and Happy Holidays!
Richard
More information about the Chicago-talk
mailing list