× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 02 Oct 2013 12:43, DeLong, Eric wrote:
Here's a block I use for some address validation...

// Remove any punctuation from the City Name.
DoW %scan(',':pAddress.City)>0;
pAddress.City = %replace('' : pAddress.City
:%scan(',':pAddress.City):1);
EndDo;
DoW %scan('.':pAddress.City)>0;
pAddress.City = %replace('' : pAddress.City
:%scan('.':pAddress.City):1);
EndDo;
DoW %scan('?':pAddress.City)>0;
pAddress.City = %replace('' : pAddress.City
:%scan('?':pAddress.City):1);
EndDo;
DoW %scan('!':pAddress.City)>0;
pAddress.City = %replace('' : pAddress.City
:%scan('!':pAddress.City):1);
EndDo;


FWiW: A [lightly tested] variant that should remove multiple unwanted characters [i.e. more than two] uses a first-pass of the data performed by an %XLATE and then a second-pass with the /same/ DOW to effect the %REPLACE, also while reducing re-scan from the beginning of the string per introduction of a starting position variable:

pAddress.City = %xlate(',.?!':'!!!!':pAddress.City) ; // bad chars
StartPos=%scan('!':pAddress.City) ; // find first char to remove
DoW StartPos>0; // an undesirable char found
pAddress.City=%replace('':pAddress.City:StartPos:1) ; // rmv char
if StartPos > %len(pAddress.City) ; // just trimmed the last char
leave ;
endif ;
StartPos=%scan('!':pAddress.City:StartPos) ; // next char to rmv
EndDo;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.