×
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 Danny,
A possible explanation can be found here (regcomp() and regexec() functions are Locale Sensitive):
http://www-01.ibm.com/support/docview.wss?uid=nas8N1010877
Cheers,
Carsten
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Danny Rodius
Sent: 5. februar 2018 11:42
To: rpg400-l@xxxxxxxxxxxx
Subject: regcomp/regexec problem
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?
As an Amazon Associate we earn from qualifying purchases.