regexmainframerexx

Facing error while executing a regular expression to find a pattern in PS file or PDS member via REXX in mainframe


In a REXX tool, I want to check if the PS file contains a specific pattern (like continuous 16 digits) in mainframe, for which I want to execute a Regular expression and then check the RC for further processing. I tried below code, but not able to execute the regular expression.

/* REXX */
STRIGN = "rc'[0-9]{16}'"
ADDRESS ISPEXEC "VIEW DATASET('XXXX.XXXXX.XXXXX')"
ADDRESS ISREDIT "MACRO (STRING)"
"F" STRING
SAY RC

For the code I am getting error for line

"F" STRING' 'IKJ56500I COMMAND F NOT FOUND' and RC = '-3'.

Could anyone please suggest any way to execute a regular expression using REXX in mainframe.


Solution

  • You'll need to create a separate ISPF edit macro containing your edit commands:

    /* REXX */
    address isredit
    "macro"
    "f rc'[0-9]{16}'"
    say rc
    

    and then specify this macro when you edit the dataset. E.g. if you create a macro called 'findnum' then you'd code:

    address ispexec                                           
      "edit dataset('XXXX.XXXXX.XXXXX') macro(findnum)" )
    

    which will cause edit to be invoked for that dataset and to run the 'findnum' macro.

    Your macro has to be in a dataset that is part of your SYSPROC or SYSEXEC concatenation.