NYCPHP Meetup

NYPHP.org

[nycphp-talk] (ir) regular expressions (stupid me)

Adam Maccabee Trachtenberg adam at trachtenberg.com
Sat Apr 24 11:58:43 EDT 2004


On Sat, 24 Apr 2004, Dan Cech wrote:

> You may in fact want to go with a 3-input solution and grab the street,
> city and state separately, unless you can be guaranteed the user will
> put in the commas.

I agree with Dan. Addresses are weird and non-standard. For instance,
in Washington, DC, this is a typical address:

1600 Pennsylvania Avenue, NW, Washington, DC

The city is divided into four quadrants, NW, NE, SW, and SE, so people
append the region to the end of the street address.

> > B) In the second case, what I want to check for seems to be much
> > simpler, but I having no luck.
>
> You can change the above preg expression by removing the [.]? which will
> disallow the use of the . character in the address, however as you can
> see in the above expression, the . character is outside the brackets for
> the address, so it is discarded if it exists anyway.
>
> Otherwise, you would have to do a negative check for 'St.', ie look for
> St., and if not found then look for St without the full stop.

And what happens for people who live in:

1000 Broadway, New York, NY

There's no St or St. or (Ave, Ave., etc.) or anything else.

Using three boxes is easier if you can swing it.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!



More information about the talk mailing list