× 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.



Im trying to use regcomp/regexec to extract emails from a long string. When i test the code, the return code is 13. Where can i find out what that means?

code:

P eminnote        B export
 *-------------------------------------------------------------------
D eminnote        PI            60 dim(20)
D  claimin                       7  0 const
D  datain                     1000 const

d data            s           1000a   inz varying
d regex_ph_nbr    ds                  inz likeds(regex_t)
d dsrm            ds                  inz likeds(regmatch_t) dim(100)
d ast             s             60 inz(*all'*')
d pattern         s           1000a   inz varying
d rc              s             10i 0 inz(0)
d rtnval          s             60 dim(20)
d rtnval_c        s              3 0
d email           s 60

  clear rtnval;
  data = datain;
  open CLPHONEL11;

pattern =
 '[a-z0-9]+([-+._][a-z0-9]+){0,2}@.*?(\.(a;'
+'(?:[cdefgilmnoqrstuwxz]|ero|(?:rp|si)a)|'
+'b(?:[abdefghijmnorstvwyz]iz)|c(?:'
+'[acdfghiklmnoruvxyz]|at|o(?:m|op))|'
+'d[ejkmoz]|e(?:[ceghrstu]|du)|f[ijkmor]|'
+'g(?:[abdefghilmnpqrstuwy]|ov)|h[kmnrtu]|'
+'i(?:[delmnoqrst]|n(?:fo|t))|j(?:[emop]|'
+'obs)|k[eghimnprwyz]|l[abcikrstuvy]|'
+'m(?:[acdeghklmnopqrstuvwxyz]|il|obi|'
+'useum)|n(?:[acefgilopruz]|ame|et)|o(?:m|'
+'rg)|p(?:[aefghklmnrstwy]|ro)|qa|r[eosuw]|'
+'s[abcdeghijklmnortuvyz]|t(?:[cdfghjklmnoprtvwz]|'
+'(?:rav)?el)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|'
+'z[amw])\b){1,2}'
;

rc = regcomp(regex_ph_nbr :pattern :REG_EXTENDED) ;
if rc = 0 ;
  dow '1' ;
    rc = regexec(regex_ph_nbr:
                 data:
                 regex_ph_nbr.re_nsub  :
                 dsrm :

    if rc <> 0 ;
      leave ;
    endif ;

    email =
%subst(data:dsrm(1).rm_so+1:dsrm(1).rm_eo-dsrm(1).rm_so);

    setll (email:claimin) clphonel11;
    if not %equal;
      rtnval_c += 1;
      rtnval(rtnval_c) = email;
endif;

    %subst(data:dsrm(1).rm_so+1:dsrm(1).rm_eo-dsrm(1).rm_so) = ast;
  enddo ;
endif ;
regfree(regex_ph_nbr) ;

close CLPHONEL11;
return rtnval;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.