|
Booth, This is what the SQL User Defined Function STRIPEMAIL() does. I created an rpg service program to do just about what you said. I was just trying to figure out what to put in the variable ValidEmailChar. /DEFINE DSpec /INCLUDE ROUTINES/QPROTOSRC,STRIPEMAIL /UNDEFINE DSpec /EJECT P STRIPEMAIL B export D STRIPEMAIL PI like(EmailAddress) D SourceString 512a const D Domain s 100a varying D Person s 100a varying D EmailAddress s 100a inz(*loval) D AtSignPos s 5i 0 inz(*zero) D BlankBefore s 5i 0 inz(*zero) D BlankAfter s 5i 0 inz(*zero) D ValidEmailChar c 'ABCDEFGHIJKLMNOPQRSTUVWXYZ- D abcdefghijklmnopqrstuvwxyz- D 0123456789/%._-' /free reset AtSignPos; reset BlankBefore; reset BlankAfter; reset EmailAddress; AtSignPos=%scan('@' : SourceString : 1); Select; When AtSignPos=0; // Invalid email address, no @ return EmailAddress; When AtSignPos<2; // Invalid email address, @ is in first position return EmailAddress; When AtSignPos>(%len(SourceString) - 2); // Invalid email address, @ is too close to end return EmailAddress; Other; // reasonable position for '@' BlankAfter=%check(ValidEmailChar : SourceString : AtSignPos + 1); Select; When BlankAfter < (5 + AtSignPos); // Invalid email address - no valid domain, even x.de takes 4 characters return EmailAddress; When BlankAfter=0; Domain=%subst(SourceString : AtSignPos + 1 : %len(SourceString) - AtSignPos); Other; Domain=%subst(SourceString : AtSignPos + 1 : BlankAfter - AtSignPos - 1); EndSl; BlankBefore=%checkr(ValidEmailChar : SourceString : AtSignPos - 1); Person=%subst(SourceString : BlankBefore + 1: AtSignPos - BlankBefore - 1); EndSl; EmailAddress=Person + '@' + Domain; return EmailAddress; /end-free P StripEmail E Rob Berendt -- "All creatures will make merry... under pain of death." -Ming the Merciless (Flash Gordon) "Booth Martin" <Booth@xxxxxxxxxxxx> Sent by: midrange-l-bounces@xxxxxxxxxxxx 01/12/2004 04:09 PM Please respond to Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx> To <midrange-l@xxxxxxxxxxxx> cc Fax to Subject Re: What are the valid characters in an email address? Since the @ sign seems to be universal to your problem can you scan for the @ signs, and then scan left and right for the first blanks or first parentheses? Could you also xlate the parentheses to blanks, then scan left and right for just the first blank? Would there be too many false positives? If there were false positives would it be serious? --------------------------------------------------------- Booth Martin http://www.MartinVT.com Booth@xxxxxxxxxxxx --------------------------------------------------------- -------Original Message------- From: Midrange Systems Technical Discussion Date: 1/12/2004 2:50:02 PM To: Midrange Systems Technical Discussion Subject: Re: What are the valid characters in an email address? Scott, In the msf journals I have one field containing several data elements. I have to strip out the email address which "generally" starts in the same place. The problem is that an acceptance and a rejection may have the same email address, however one may have put the <...> around it. I am trying to strip it down to the basics so that they look the same. Then I am going to use SQL to find sends without either an acceptance or a rejection. Bad enough I am using a UDF to strip out the email. Using a UDF to validate domain names via your method may get even slower. _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.