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



Hi,



Trying to use regex() and base my pgm on the example found in the redbook
"Who Knew You Could Do That

with RPG IV"



I checked already the used pattern in some different checkers found on the
web and the all came up to check almost every email.



However when using in my program it seems allways to retuen that the email
address provided is wrong, even with a valid one.



Hereby my source:

ctl-opt main(main) dftactgrp(*no);



/copy cregexpr



// Main routine



dcl-proc main;

dcl-pi main extpgm('STL9110P');

PxEMail char(1024);

PxOK int(10);

end-pi;



dcl-c RegPattern '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';

dcl-s RegString varchar(1024);

dcl-ds reg likeds(C_regex_t);

dcl-ds pmatch likeds(C_regmatch_t) dim(1);

dcl-s rc int(10) inz(9);

dcl-s cflags int(10);



cflags = REG_EXTENDED + REG_ICASE + REG_NOSUB;



if (regcomp(reg: RegPattern: cflags) = 0);

RegString = %trim(PxEMail);

rc = regexec(reg: RegString: %elem(pmatch): pmatch: 0);

if rc = 0;

PxOK = 0;

else;

PxOK = 1;

EndIf;

endif;



regfree(reg);

end-proc;



My hope that there is someone here who could point me out what I'm doing
wrong.



Regards,

Danny




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.