Development and Pipeline

 View Only

 COBOL using REGCOMP and REGEXEC

Douglas Landholt's profile image
Douglas Landholt posted 06/04/26 05:15 PM

I'm trying to use COBOL to match text strings (mainframe and server file names) to Regular Expressions used in our File Transfer system to determine the transmission route IDs for our input and output files. I'm using REGCOMP and REGEXEC modules in CEE.SCEELKED, statically linked to the calling program. I got some AI help to set up parameters and structure the calls. I was getting S0C4s using COBOL 6.4, but at least sidestepped the crashes by downshifting to COBOL 4.2. 

My current hurdle is that the REGEXEC function sends back a return code of 1 (no match) even for files that should match. If there's anyone out there with experience using these functions, any help would be greatly appreciated!!

Daniel Barraza's profile image
Daniel Barraza

Douglas, looks like you got this working over in the COBOL group, nice: https://community.ibm.com/community/user/question/using-enterprise-cobol-to-call-c-regcomp-regex-functions. Dropping the link here for anyone who lands on this thread later. Short version of what fixed it: pass the fullword arguments BY VALUE, use null terminated z'...' literals (or append x'00' yourself), and set the locale with CEESETL so it matches the codepage your source was compiled with. Otherwise characters like $ and [ don't mean what the regex engine thinks they mean. Frank's and Denis's sample programs in that thread are a great starting point.