RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Validating The Form of an Email Address Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   

Posted to the RPG400 mailing list, http://midrange.com , by John King on 02/27/07.

P IsValidEmailFmt...
P                 B                   export
D IsValidEMailFmt...
D                 PI             1N
D   address                   1024A   const varying

D RegPattern      S                   like( StdStr )
D RegString       S                   like( StdStr )
D reg             ds                  likeds(regex_t)
D match           ds                  likeds(regmatch_t)
D buf             s             80A
D rc              s             10I 0

  // Regex stolen from: http://www.regular-expressions.info/email.html
  // Note this is "extended syntax". Basic syntax doesn't handle the + sign.
  // Ignoring case, it checks for:
  // 1) starting at the beginning of the string
  // 2) "one or more" from the list of [A-Z0-9._%-]
  // 3) an '@' sign
  // 4) "one or more" from the list of [A-Z0-9._%-]
  // 5) a "." (the . must be escaped with the \ symbol)
  // 6) between 2-4 characters from the list of [A-Z]
  // 7) at the end of the string
  RegPattern = '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';
  rc = regcomp(reg: %trimr(RegPattern): REG_EXTENDED+REG_ICASE+REG_NOSUB);
  RegString = address;
  rc = regexec(reg: %trim(RegString): 0: match: 0);
  if rc = 0;
    return *on;
    return *off;

P IsValidEmailFmt...
P                 E

User Comments

Please login or register to add comments

<Previous   Next>