Anbei das modifizierte Programm (JAVA in Copy-Strecke ausgelagert), damit es einfacher lesbar ist

PHP-Code:
         ctl-opt dftactgrp(*noalloc(*teraspacemain(main);
      
//------------------------------------------------------------------//
      //                                                                  //
      // Test - Regex with JAVA                                           //
      //                                                                  //
      //-----------------                                                 //
      // R.Ross 11.2021 *                                                 //
      //------------------------------------------------------------------//
      // Prototypes                                                       //
      //------------------------------------------------------------------//

      
/include QSYSINC/QRPGLESRC,JNI
      
/include DEVS/QCPYSRC,REGEXJAVA

      
//------------------------------------------------------------------//
      // Main                                                             //
      //------------------------------------------------------------------//
         
dcl-proc main;

         
dcl-s   LocPattern  varchar(256);
         
dcl-s   LocString   varchar(256);

         
dcl-s   LocGroup0   char(50);
         
dcl-s   LocGroup1   char(50);
         
dcl-s   LocGroup2   char(50);
         
dcl-s   LocGroup3   char(50);

           
LocPattern   '(<div class="card">)([\s\S]*?)(</div>)';

           
LocString    '</div><div class="card">abcdex</div>' +
                          
'<div>sdfssdf</div>' +
                          
'<div class="card">bsdfsd</div></div>';

           
RegPattern   newString(LocPattern);
           
RegString    newString(LocString);

           
RegExMatcher Matcher(Compile(RegPattern):RegString);

           
dow Find(RegExMatcher) = *on;
             
LocGroup0 getBytes(Group((RegExMatcher):0));
             
LocGroup1 getBytes(Group((RegExMatcher):1));
             
LocGroup2 getBytes(Group((RegExMatcher):2));
             
LocGroup3 getBytes(Group((RegExMatcher):3));
           
enddo;

         
end-proc;
      
//------------------------------------------------------------------// 
und die Copy-Strecke

PHP-Code:
      //------------------------------------------------------------------//
      // JAVA String 1 MB                                                 //
      //------------------------------------------------------------------//

         
dcl-pr  newString   like(JAVA_String)
                             
extproc(*JAVA:'java.lang.String':*constructor);
                  
Value      varchar(1000000) const;
         
end-pr;

      
//------------------------------------------------------------------//
      // Get Bytes                                                        //
      //------------------------------------------------------------------//

         
dcl-pr  getBytes    varchar(100000)
                             
extproc(*JAVA:'java.lang.String':'getBytes');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Compile                                                    //
      //------------------------------------------------------------------//

         
dcl-pr  Compile     object(*JAVA:'java.util.regex.Pattern')
                             
extproc(*JAVA:'java.util.regex.Pattern':
                                           
'compile') static;
                  
Pattern    like(JAVA_String);
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Matcher                                                    //
      //------------------------------------------------------------------//

         
dcl-pr  Matcher     object(*JAVA:'java.util.regex.Matcher')
                             
extproc(*JAVA:'java.util.regex.Pattern':'matcher');
                  
String     object(*JAVA:'java.lang.CharSequence');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Matches                                                    //
      //------------------------------------------------------------------//

         
dcl-pr  Matches     ind
                             extproc
(*JAVA:'java.util.regex.Matcher':'matches');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Find                                                       //
      //------------------------------------------------------------------//

         
dcl-pr  Find        ind
                             extproc
(*JAVA:'java.util.regex.Matcher':'find');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Start Position from Find                                   //
      //------------------------------------------------------------------//

         
dcl-pr  Start       int(10)
                             
extproc(*JAVA:'java.util.regex.Matcher':'start');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex End   Position from Find                                   //
      //------------------------------------------------------------------//

         
dcl-pr  End         int(10)
                             
extproc(*JAVA:'java.util.regex.Matcher':'end');
         
end-pr;

      
//------------------------------------------------------------------//
      // Regex Group                                                      //
      //------------------------------------------------------------------//

         
dcl-pr  Group       object(*JAVA:'java.lang.String')
                             
extproc(*JAVA:'java.util.regex.Matcher':'group');
                  
Index      int(10value;
         
end-pr;

      
//------------------------------------------------------------------//
      // Variables                                                        //
      //------------------------------------------------------------------//

         
dcl-s   JAVA_String  object(*JAVA:'java.lang.String');

         
dcl-s   RegExPattern object(*JAVA:'java.util.regex.Pattern');
         
dcl-s   RegExMatcher object(*JAVA:'java.util.regex.Matcher');

         
dcl-s   RegPattern   like(JString);
         
dcl-s   RegString    like(JString);

      
//------------------------------------------------------------------//