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


  • Subject: regcomp/regexec problem
  • From: "Danny Rodius" <danny.rodius@xxxxxxxxx>
  • Date: Mon, 5 Feb 2018 11:42:08 +0100
  • Ironport-phdr: 9a23:a38LXRD1l3kJSYFy6DDKUyQJP3N1i/DPJgcQr6AfoPdwSPv7rsbcNUDSrc9gkEXOFd2Cra4c0qyO6+jJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglUmTaxe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfOpWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnMVhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Xymp4aV2Rx/ykCoJNyA3/nzZhMJzg61UvBWvpwBkzoHOfI2VO+Jzcr3Bcd8EQ2dKQ8ZfVzZGAoO5d4YDAeQPMvxer4n7p1oFsAewBQ6xC+Pu1z9InXH61rA93us8Cw7G2gogHtIUvHTOq9X6KaYSUf2uzKTT1jXDbPNX2THj54jUaBwuuu+DUKt2fMHMykcvDxvIg1aNpYD/IT+Y2esAv3KF4+dvVe+jkXMrpgNxrzWp28wikJPGhpgPxVDB7Sh5xYE1KsCmR0Njet6kFYdQtzmdN4trXsMuW2Fotzg+yr0BoZO1cjIFyJIhxx/fcfKKbZCE4hPlVOmPPTd1nHFodK+lixqs/kWtxffwWte73VtKtCZJj9vBu3AV2xzW8MeHS/99/km72TaI0gDe8vxLLloylardK58t2KQwlp0OvkTCAy/2g177jLSVdkQk/Oin9fjnbq/9qZCCL4N0kB3xMrwymsyjBuQ1KhIOX3CU+emzyLHv4VT1QLFRg/0zk6nWrYraKt4dpq62HQBZyJos6xG6D2Tu7NNNyWMfIw4dIFeDp43oN0vHJv/1S/y4hgL/vi1swqWMErTnBISFFH/Pkar6N/4p50dazht119dT5o9PIqoCMfT+Rgn7uYqLXVcCLwWozrO/W51G3YQEVDfXDw==
  • List-archive: <https://archive.midrange.com/rpg400-l/>
  • List-help: <mailto:rpg400-l-request@midrange.com?subject=help>
  • List-id: "RPG programming on the IBM i \(AS/400 and iSeries\)" <rpg400-l.midrange.com>
  • List-post: <mailto:rpg400-l@midrange.com>
  • List-subscribe: <https://lists.midrange.com/mailman/listinfo/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=subscribe>
  • List-unsubscribe: <https://lists.midrange.com/mailman/options/rpg400-l>, <mailto:rpg400-l-request@midrange.com?subject=unsubscribe>

Hi,



Want to validate a field with the regular expression support.

Took a look at the example in "Who Knew You Could Do That with RPG IV"
redbook and wrote the following code:



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

/copy cregexpr

dcl-proc main;

dcl-pi main extpgm('STL9120P');

PxOrderNbr char(8);

PxOK char(1);

end-pi;



dcl-s RegPattern varchar(50);

dcl-ds preg 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;

RegPattern = '^[A-Z0-9-_]$';

rc = regcomp(preg: RegPattern: cflags);

if ( rc = 0);

rc = regexec( preg: %trim(PxOrderNbr): %elem(pmatch): pmatch: 0);

PxOK = %char(rc);

endif;

regfree(preg);

return;

end-proc;



When calling with first parm = '12345678' it return allways 1 (not equal).



The regexec seems not to work. So what I'm doing wrong, where I have failed?

Anyone already used the regcomp/regexec combination to test a field?

Know that I can do it with SQL but want to have it in plain RPG.



Anyone








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.