× 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: RE: regcomp/regexec problem
  • From: "Danny Rodius" <danny.rodius@xxxxxxxxx>
  • Date: Wed, 7 Feb 2018 13:50:43 +0100
  • Ironport-phdr: 9a23:4emh7xI2gsE0TdjTqNmcpTZWNBhigK39O0sv0rFitYgfL/nxwZ3uMQTl6Ol3ixeRBMOHs6sC07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffxhEiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QrcpVzS/9KdrUAHnhzsbNzA392HXj9Z/jKNdoBm8oxByzIrZbISTOfFjfK3SYMkaSHJBUMhPWSxOAJ6yYYUMAeUOIelWqJX9qkALrReiCgmhHP3jxiNWinLwwKY00/4hEQbD3AE4Ed4Avm7brNPzNKYSTOu70K7IwijCb/NLwjfx5pXDfxc8rv6WW7Jwd8rQxVM1FwPCk1qQqJHlPyiO2+QWsGia7+xgWvyzi2I9sA5+vCGiy8ExgYfHgYIVz0rL9SR/wIstIN24SVN0YcS+H5tWuCGVKZF6Td8lQ2FtoCo10LgGtoS6fSgNzpQr3QLQa/uCc4SQ4xLsT+ORLS1ki3JifbKznwy98U2hy+36TMW0zFFKoyxYmdfPrnAAzwHf58yIR/dn/Eqs2iyD2x3T5+xHO0w5mqzWIIM7zLEqjJocq0HDEzfzmEXxkaCZaF0p+vOt6+T7erXmoYKcN5NshgH+LKsunsu/DPw2PAcUWWib/+S92qf98EHhQbVKiOM5krXBvZzHIckWqbS1Dg1W34o59hqyDzSr3M4XkHUfKVJKYhOHj4znO1HUJ/D4CO+yjEm2nzdtwfDHPqftAo/KLnfekbfhYK195lVHyAowzdFf4YxbCq0bLP3oRED9rMbYAQMhMwyo3+bnD81w1pkGWWKADaKVLL/evUaM5u80JumMZZIauCznJPgj6P7hk2U1lkMafamsjtMqbmulFKFmP1mBeiirxdMACnsR+A8/QPbjjlKPFzVUYjG3VqM44zg9T4anFpvCQI6qx6aZ03vjRthSNVxBXxrDK0/HP52eXPgWYSeXI8lu2jsCHaShRscA/zTmtUfOi5NcabaMomURs56r1eN4/ezejiVzunY8W96F3D3VFyRwtmYJSyU/2q9y50d6zwHQ/7J/hqkSOdVV4eIBaAA2NIPHhaQuB9n0XBOHZNCFSUu9as6lEDc8UpQ7zoldMA5GB9y+g0WbjGKRCLgPmunXVZE=
  • 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 Thomas,

thanks for this info.
Have included this and now the regcomp is working, but still the regexec is
not working.
We the program with a valid ordernbr and still the regexex returns a 1.

Program source as attachment

Any other ideas.

Already copied a number of examples but none of them seems to work. Is there
something special about this
That I'm overlooking?

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Tools/400
Sent: dinsdag 6 februari 2018 22:43
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: regcomp/regexec problem

It is correct that LOCALETYPE is specific to C/CPP. I assume that I actually
wanted to add the following URL, which describes the usage of
setLocale():

http://www-01.ibm.com/support/docview.wss?uid=nas8N1012446

Thomas.

Am 06.02.2018 um 11:53 schrieb Danny Rodius:
Hi all,

Taken some of your remarks into account and this is the followup:

To Carsten,

Have checked this locale stuff and settings QLOCALE =
/QSYS.LIB/EN_BE.LOCALE Job CCSID = 1148 Seems a valid combination.

To David,

Like to follow the regcomp/regexec path instead of the SQL.
But have tried your expression and got now a return code 11. Even with
the extended flag on.

To Thomas,

Maybe I'm missing something but LOCALETYPE(...) seems only to exist on
the compiler command for C/CPP.

General, I'm still searching
Any other ideas

BR+
Danny


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Flensburg, Carsten
Sent: maandag 5 februari 2018 15:04
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxx>
Subject: RE: regcomp/regexec problem

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?


--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:
http://amzn.to/2dEadiD


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
ctl-opt main(main) dftactgrp(*no);

/copy z0stlps/qcpysrc,cregexpr

dcl-pr setlocale pointer extproc('_C_PSX_setlocale');
category int(10) value;
localetype pointer value options(*string);
end-pr;

// Main routine

dcl-proc main;
dcl-pi main extpgm('STL9125P');
PxOrderNbr char(8);
PxOK char(1);
end-pi;

dcl-c LC_ALL -1;
dcl-c LOCALETYPE_POSIX 'POSIX';
dcl-s oldLocaleSave varchar(1000);
dcl-s oldLocalePtr pointer;

dcl-s RegPattern varchar(50);

dcl-s RegString varchar(10);
dcl-ds reg likeds(C_regex_t);
dcl-ds pmatch likeds(C_regmatch_t);
dcl-s rc int(10) inz(9);
dcl-s cflags int(10);

// Save actual local and set new local
oldLocalePtr = setlocale (LC_ALL : *NULL);
oldLocaleSave = %str(oldLocalePtr);
// set the locale
setlocale (LC_ALL : LOCALETYPE_POSIX);
// do the locale-sensitive function

cflags = REG_EXTENDED + REG_ICASE;

RegPattern = '^[A-Z0-9-_]{1,8}$';

rc = regcomp(reg: RegPattern: cflags);

if ( rc = 0);
RegString = %trim(PxOrderNbr);
rc = regexec(reg: RegString: 1: pmatch: 0);
PxOK = %char(rc);
endif;

regfree(reg);

//Set initial local back
setlocale (LC_ALL : oldLocaleSave);

return;

end-proc;

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.