// used ONLY to actualy now finally get the actual values - IMP public void ParsePropertyDetail(ref Match tmatch, string WideCondition, string NarrowCondition, ref PropertyDetails pd) { // property details pd.isApt = false; pd.City = ""; pd.State = "Georgia"; pd.Address = ""; pd.AptNo = ""; pd.ZipCode = 0; pd.SQLlink = 0; // All of them have an address field pd.Address = p_Cleanup.AddressCleanup(tmatch.Groups["addr"].ToString()); // 1) ZipCode Specific Parsing if ((NarrowCondition == "ZipCode") && (WideCondition == "COMMON_KNOWN_AS" || WideCondition == "COMMON_IS_LOCATED")) { if (p_DailyReport.isValidStr(tmatch.Groups["zip"])) { pd.ZipCode = int.Parse(tmatch.Groups["zip"].ToString()); } } // 2) 3) 4) Most others fall in here else if (((NarrowCondition == "Georgia") || (NarrowCondition == "GA") || (NarrowCondition == "no Zip or State")) && (WideCondition == "COMMON_KNOWN_AS")) { // exception state if (NarrowCondition == "no Zip or State") { // Can't get city out + need to manually get out the Address Info p_Cleanup.isRemovedEverythingAfterStreetName(ref pd.Address); } else { pd.City = p_Cleanup.CityCleanup(tmatch.Groups["city"].ToString(), 5, true); } } // 2) exception a few fall in here else if (((NarrowCondition == "Georgia")) && ((WideCondition == "COMMON_IS_LOCATED") || (WideCondition == "COMMON_ENCUMBERED_PR"))) { pd.City = p_Cleanup.CityCleanup(tmatch.Groups["city"].ToString(), 5, true); } // All of them try to assign Apartments string tno; // Some of them could have city info in the city, so check city first // (only in Georgia Condition) - that is where it actually occurs //if (NarrowCondition == "Georgia" && pd.City != "") //{ // pd.isApt = p_Cleanup.isApartment(tmatch.Groups["city"].ToString(), out tno); //} // Otherwise just check the address and assign it if neccessary //if (!(pd.isApt) && (pd.isApt = p_Cleanup.isApartment(pd.Address, out tno)) && (tno != "")) //{ // pd.AptNo = tno; //} }
public bool isApartment(string toCheck, out string AptNo) { // temp Regex temprx = new Regex(""); // assigning it a default value so the compiler // won't complain Match tmatch; AptNo = ""; bool isApt = false; if (toCheck.Contains("#")) { isApt = true; //temprx = new Regex(@"\s*#\s*(?<aptno>\d{2,4})(?<suffix>\w*)\s"); } else if (toCheck.ToUpper().Contains("APT")) { isApt = true; //temprx = new Regex(@"\s*[Aa][Pp][Tt].?\s*(?<aptno>\d{2,4})(?<suffix>\w*)\s"); } else if (toCheck.ToUpper().Contains("UNIT")) { isApt = true; //temprx = new Regex(@"\s*[Uu][Nn][Ii][Tt].+?\s*(?<aptno>\d{2,4})(?<suffix>\w*)\s)"); } else if (toCheck.ToUpper().Contains("SUITE")) { isApt = true; //temprx = new Regex(@"\s*[Ss][Uu][Ii][Tt][Ee].+?\s*(?<aptno>\d{2,4})(?<suffix>\w*)\s)"); } else { // If it contains a number at the beginning, a // string of chars in between and a digit at the end // it is an apartment - this mimiks a regular expression bool bBeginningNumber = false; bool bMiddleString = false; bool bEndNumber = false; foreach (char c in toCheck) { if (char.IsDigit(c) && !bMiddleString) { bBeginningNumber = true; } else if (char.IsLetter(c) && bBeginningNumber) { bMiddleString = true; } else if (char.IsDigit(c) && bMiddleString) { bEndNumber = true; } } if (bEndNumber) { isApt = true; //temprx = new Regex(@"\d{2,4}-?\d*\s+.{10,100}\s*(?<aptno>\d{2,4})(?<suffix>\w*)\s)"); } } // If it is an apartment try parsing out the Apartment Number! if (isApt) { tmatch = temprx.Match(toCheck); if (p_DailyReport.isValidStr(tmatch.Groups["aptno"])) { int tint; if (int.TryParse(tmatch.Groups["aptno"].ToString(), out tint)) { AptNo += (tint.ToString() + tmatch.Groups["suffix"].ToString()); } } } return(isApt); }