Not to discourage you, as I'm sure porting PCRE to z/OS is a fine idea, but it 
would not be true to say that regex processing is not available for COBOL (or 
PL/I) on z/OS.  I was looking through the IBM XL C/C++ for z/OS Run-Time 
Library Reference the other day (god knows why, since I don't even have access 
to XL C/C++) and noticed that there were some regular expression features.

So I just took about 30 minutes and came up with this COBOL program (based on C 
code found here: 
http://stackoverflow.com/questions/1085083/regular-expressions-in-c-examples):

       process nodynam pgmname(mixed)
       process codepage(1047)
       identification division.
       program-id.  'regex1'.
       data division.
       working-storage section.
       01  regex.
           05  re_nsub         comp-5    pic s9(8).
           05  re_comp         pointer.
           05  re_cflags       comp-5    pic s9(8).
           05  re_erroff       comp-5    pic s9(8).
           05  re_len          comp-5    pic s9(8).
           05  re_ucoll        comp-5    pic s9(4)  occurs 2.
           05  re_lsub         pointer              occurs 10.
           05  re_esub         pointer              occurs 10.
           05  re_map          display   pic x(256).
           05  re_shift        comp-5    pic s9(4).
           05  re_dbcs         comp-5    pic s9(4).
       77  reti                comp-5    pic s9(8).
       77  msgbuf              display   pic x(100).

       procedure division.
           call 'regcomp' using regex
                                content z"^a[[:alnum:]]"
                                value 0
                returning reti
           if reti is not equal to zero
               display 'Count not compile regex'
               stop run
           end-if
           call 'regexec' using regex
                                content z'abc'
                                value 0 0 0
                returning reti
           perform check-reti
           call 'regexec' using regex
                                content z'qxp'
                                value 0 0 0
                returning reti
           perform check-reti
           call 'regfree' using regex
           goback.

       check-reti.
           evaluate reti
           when zero
               display 'match'
           when 1
               display 'no match'
           when other
               call 'regerror'
               display 'Regex match failed: ' msgbuf
               stop run
           end-evaluate
           .

       end program 'regex1'.



It compiles and runs fine, with the following results:
match
no match

Pretty cool, I must say!
FWIW, I didn't need to have the regex data item be the group data item as 
above.  I could have just made it a DISPLAY PIC X(364), since I'm not referring 
to any of the fields within the group in my COBOL program.

Frank




>________________________________
> From: Ze'ev Atlas <[email protected]>
>To: [email protected] 
>Sent: Wednesday, July 3, 2013 6:35 AM
>Subject: Re: Announcing PCRE 8.33 for native z/OS
> 
>
>Hi All
>Of all places, I would expect a little more enthusiasm of the members of this 
>list.
>
>Let me please explain the rationale behind publishing the PCRE library on z/OS.
>
>Regular expressions are available in most modern languages such as Perl, Java 
>and PHP, to mention only few (BTW, PHP is using the PCRE library for regular 
>expressions processing.)  Regular expressions are used extensively and are 
>basic part of life in programming and handling data on Linux, Unix (and by 
>extension on z/OS with USS and MVS-OE) and Windows.
>
>This capability was virtually unavailable on native z/OS and not at all for 
>grand old COBOL and PL/I.  By porting this library, i brought this awesome 
>capability into the native z/OS realm and into the LE languages functionality. 
> And thus. I pulled COBOL and PL/I kicking and screaming to the 21st century.
>
>Rexx on z/OS is an untamed beast and I do not know how to approach it.  We 
>really need volunteers for that aspect.
>
>Object Rexx (on non z/OS platform) appears to be catching up with that trend 
>and lately added a RxRegExp library.  I did not yet have a chance to look at 
>it yet, but I know that there was a Posix compliant library available for non 
>z/OS Rexx for some time.
>
>While the package in full is available on my website in both ASCII form and 
>EBCDIC XMIT libraries, all you really need may be the XMIT libraries, the 
>documentation and the license document.  There is one XMIT library missing 
>(the test cases) but I hope to add it soon and it is not crucial for working 
>with the library.
>
>I had a rough start some months ago when I first published the package (PCRE 
>8.31) but this was my first time publishing open source on serious scale.  The 
>current package is stable and available.
>
>ZA
>
>----------------------------------------------------------------------
>For IBM-MAIN subscribe / signoff / archive access instructions,
>send email to [email protected] with the message: INFO IBM-MAIN
>
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to