Hi Shane, You have two main problems here: One is to split off the "number" part of the address from the street name. The other is to convert abbreviations of street suffixes such as St., Ave., and Blvd. into their non-abbreviated equivalents. Each of these problems poses its own set of challenges.
For splitting off the number, you face some issues of non-standardization, similar to the problems I mentioned in the thread about name capitalization. The "number" part of the address is not always just numbers, since some addresses can look like "34W56 Main St." So you can't just remove the number from the beginning. And sometimes the number part is more than one word, such as "24 1/2 Crowded Lane." As for expanding the street suffix abbreviations, that's also not quite straightforward. For one thing, the comprehensive list of official USPS street suffix abbreviations is very large: http://www.usps.com/ncsc/lookups/usps_abbreviations.html#suffix Or: http://www.usps.com/ncsc/lookups/abbr_suffix.txt This list may not include other informal abbreviations, and other conventions outside the U.S. Also, the address in your data may not include the street suffix at all, such as "17 N. Main," which can make it difficult, if not impossible, to determine whether or not the last word is indeed a suffix designation, let alone what the correct suffix should be if it's not specified. Furthermore, some addresses on rural routes and such may not have a suffix at all, and which may include a number at the end, such as "5566 Rural Route 34" or "9368 State Highway 20". In other cases, there may even be no number, street, or suffix at all, such as addresses in large buildings with their own ZIP codes, such as the Merchandise Mart here in Chicago. The address "Suite 470, The Merchandise Mart, Chicago, IL 60654" is perfectly valid. And of course, you may have addresses in your data which are simply P.O. boxes, in which case there is neither a street name nor a suffix, but the address is still obviously valid. In addition, if you're trying to "un-abbreviate" everything, you may also want to expand direction abbreviations (N, S, E, W, etc.) As you can see, this type of thing can be very complicated, and there are some fairly expensive solutions for just this kind of address validation and conversion on the market. That said, if you want to try to tackle this, you can make some assumptions that will cover *most* of the possibilities. For the number, you can assume that the first word which starts with a letter, and not a numeric digit, represents the street name. For the street suffix, you can just create a table of abbreviations and their replacements and assume that if you don't get a match, you can append the word "Street." And you can strip off any trailing period that's part of the abbreviation. Something like: var Address = "123 1/2 N. Main St."; var StreetNamePos = Address.search(/\b[A-Z]/gi); var StreetName = Address.substring(StreetNamePos); var StreetSuffixAbbrMap = { "St" : "Street", "Ave" : "Avenue", "Blvd" : "Boulevard", // Add ALL of the abbreviations from this page: // http://www.usps.com/ncsc/lookups/abbr_suffix.txt }; var foundSuffix = false; for (var i in StreetSuffixAbbrMap) { var re = RegExp("\\b" + i + "\\b", "gi"); if (StreetName.search(re) > -1) foundSuffix = true; StreetName = StreetName.replace(re, StreetSuffixAbbrMap[i]); } StreetName = StreetName.replace(/\.$/, ""); if (!foundSuffix) StreetName += " Street"; return StreetName; Note the comment that you would need to add all of the possible street suffix abbreviations to be comprehensive. You may still run into some of the problems I listed above as well. But this should be a workable "poor man's" solution. Dan +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Calling all FP Web Users! Do you have a question or lots of knowledge to share about FusionPro Web? If so, join our Printable Web to Print Users' Forum today! Send email to [EMAIL PROTECTED] to find out how! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -- Users of FusionPro Desktop have unlimited free email support. Contact Printable Support at [EMAIL PROTECTED] -- View FusionPro Knowledge Base, FusionPro Samples at www.printable.com/vdp/desktop.htm -- You are currently subscribed to fusionpro as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] -- -- Note: All e-mail sent to or from this address will be received or otherwise recorded by the e-mail recipients of this forum. It is subject to archival, monitoring or review by, and/or disclosure to someone other than the recipient. Our privacy policy is posted on www.printplanet.com --
