This type of thing is very complex. Some companies are completely based on providing this feature.
I would not recommend this; existing libraries and services exist for this:
https://www.usps.com/business/address-management-products.htm
http://smartystreets.com/products/liveaddress-api
If these are not parameters, and if the link link (http://stackoverflow.com/questions/824588/address-match-key-algorithm) does not help you, you will basically have to cook everything down to some common denominator. for example, divide the line into its component parts (street number, street number suffix, unit / number number, street name, street type and street direction). Then convert all possible abbreviations for each (if applicable) to this common denominator. In the case of the type of street "St." You can choose a “street” for a common denominator, in which case you convert “St.” or “St” to “Street”, then make any match - if all the data in your database contains a “street” for this type of street .
source share