After reading though How does \G work in .split? I quickly set up a Delphi program to check how PCRE handles this case. Interestingly the results were not the same as in the java case:
program Project1;
{$APPTYPE CONSOLE}
uses
System.RegularExpressions;
var
SArr: TArray<string>;
S: string;
begin
SArr := TRegex.Split('abcdefghij', '(?<=\G..)',[]);
for S in SArr do
begin
WriteLn(S);
end;
ReadLn;
end.
Outputs:
ab
cde
fgh
ij
Why does the PCRE result differ from the Java one? How is this behaviour to be explained?
To make sure this isn't an Delphi error, I tested in regex 101 and the matching behaviour seems to be the same: https://regex101.com/r/GE6eRI/1