I have a report that lists crimes occuring on different addresses within our city. I would like to take out the street number from the address field and just show the street names only. What would the formula look like?
// Formula to remove the leading numeric values (and spaces) from a string
//
// To use, replace the text assigned to OldString with your address field
//
For i := 1 to len(OldString)
do
(
If not (IsNumeric (OldString) or
OldString = " " then
(
NewString := Mid (OldString, i, len(OldString) - i +1);
Exit for
);
);
Sorry, using i as a counter caused some formatting problems, here's the formula again
// Formula to remove the leading numeric values (and spaces) from a string
//
// To use, replace the text assigned to OldString with your address field
//
For j := 1 to len(OldString)
do
(
If not (IsNumeric (OldString[j]) or
OldString[j] = " " then
(
NewString := Mid (OldString, j, (len(OldString) - j) +1 );
Exit for
);
);
Ahhh, good point, Steve, I should have checked for isnumeric:
if isnumeric(left({Customer.Address1},instr({Customer.Address1}," ")) then
mid({Customer.Address1},instr({Customer.Address1}," "+1)
else
{Customer.Address1}
I tend to avoid using variables because they destroy pass through SQL, so I just don't use them anywhere anymore unless required (looping, etc.).
Ahhh, good point, Steve, I could have at least checked isnumeric:
if isnumeric(left({Customer.Address1},instr({Customer.Address1}," ")) then
mid({Customer.Address1},instr({Customer.Address1}," "+1)
else
{Customer.Address1}
I tend to avoid using variables because they destroy pass through SQL, so I just don't use them anywhere anymore unless required (looping, etc.).
BTW, that's far from foolproof, addresses such as 49A Main Street would not get stripped.
The best solution is to use software to parse the address into each component, the next would be to write some lengthy code to perform numerous checks, including your isnumeric, failing that, check for anything within the first part that is numeric, and that there's logical information after that part (contains St., Rd., Street, Road, etc.). Also there's usually more than one address line in a database, so getting software that reads the addresses and then writes (to different fields so as not to destroy the integrity) the USPS standardized address information, as well as being able to parse into different components is very ijmportant, especially when trying to dedupe a large mailing list (mailings can be VERY expensive).
I wrote a very comprehensive Fox program in the late 80's to accomplish this as the market software was weak and very expensive. To get very accurate information I had lookup tables and ever increasing exceptions.
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.