As a start, if you did a Val() statement on either of your examples, it
would return the street number (4853). Val() returns the first number in a
string. You could then trim the original string based on the length of
whatever was returned by the Val().
That's not going to account for people entering something like "One Flower
Blossom Avenue".
I don't see how you can handle that with functions or regex. The most
accurate way is probably going to be making the form fields stricter (one
field for number, one for street, etc.). I know you said you'd rather not
do that, but if you want to be able to handle the data this way, it's
probably your best way to ensure accurate data.
HTH,
Evan
> -----Original Message-----
> From: Eron Cohen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 13, 2001 10:52 PM
> To: CF-Talk
> Subject: Parsing Street Address
>
>
> Hi Everyone,
>
> I am wondering if anyone has any code or any ideas
> about the most efficient way to handle this:
>
> I need to parse the street address from people's
> accounts such that I can parse out the Street Name and
> Street Number separately (and disregard things like
> suite and apartment number) and assign each to a
> variable.
>
> In other words, say I was given an address like:
>
> 4853 Flower Blossom Avenue
>
> Or
>
> 4853 Flower Blossom Avenue Apartment 1222
>
> I need to get the street number (4853) and then just
> the street name (Flower Blossom Avenue) and pop them
> into a variable.
>
> Would this best be done with Regular Expressions?
> Does anyone have any example code? I could force
> people to enter their street addresses in a strict
> manner to make this easy, but I'd rather not do that.
>
> Thanks,
>
> Eron
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists