Parsing the Address string

Discussion in 'MFC' started by pranit saindani, Jul 8, 2010.

  1. pranit saindani

    pranit saindani New Member

    Joined:
    Jul 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    for example if user enters Passing the parseAddress function "A. P. Croll & Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947" returns:

    2299 Lewes-Georgetown Hwy
    A. P. Croll & Son
    Georgetown
    DE
    19947

    i have thought of the following algorithm but i am having trouble implementing it...can anyone help me write the code? i know C and a bit of C++, so would prefer if the code was in these languages..

    my algo

    1)Work backward. Start from the zip code, which will be near the end, and in one of two known formats: XXXXX or XXXXX-XXXX. If this doesn't appear, you can assume you're in the city, state portion, below.

    The next thing, before the zip, is going to be the state, and it'll be either in a two-letter format, or as words. You know what these will be, too -- there's only 50 of them. Also, you could soundex the words to help compensate for spelling errors.
    before that is the city, and it's probably on the same line as the state.

    You could use a zip-code database to check the city and state based on the zip, or at least use it as a BS detector.
    The street address will generally be one or two lines. The second line will generally be the suite number if there is one, but it could also be a PO box.

    It's going to be near-impossible to detect a name on the first or second line, though if it's not prefixed with a number (or if it's prefixed with an "attn:" or "attention to:" it could give you a hint as to whether it's a name or an address line.

    any help would be appreciated
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice