anchor.diff:       end;
        LastPosition:=CurrentPosition;
        if SimpleReplacement then begin
  -      result:=result+PtrCopy(PAnsiChar(AReplacement),0,AReplacementLength);
  +      result:=result+PtrCopy(PAnsiChar(Replacement),0,ReplacementLength);
        end else begin
         i:=0;
  -      while i<AReplacementLength do begin
  -       c:=PAnsiChar(AReplacement)[i];
  +      while i<ReplacementLength do begin
  +       c:=PAnsiChar(Replacement)[i];
          case c of
           '$','\':begin
            cc:=c;
            inc(i);
  -         if i<AReplacementLength then begin
  -          c:=PAnsiChar(AReplacement)[i];
  +         if i<ReplacementLength then begin
  +          c:=PAnsiChar(Replacement)[i];
             case c of
              '$':begin
               if cc='$' then begin
  
positive.code:  result:='';
   Captures:=nil;
   try                       
    SimpleReplacement:=(PtrPosChar('$',AReplacement,AReplacementLength)<0) and (PtrPosChar('\',AReplacement,AReplacementLength)<0);
    CurrentPosition:=StartPosition;
    LastPosition:=CurrentPosition;
    if CurrentPosition>=0 then begin
  
negative.code:  if assigned(Instance) then begin
    try
     if assigned(RegularExpression) then begin
      s:='';
      try
       s:=TFLRE(Instance).DumpRegularExpression;
       Len:=length(s);
       if Len>0 then begin
        GetMem(RegularExpression^,(Len+1)*SizeOf(AnsiChar));
        Move(s[1],RegularExpression^[0],Len);
        RegularExpression^[Len]:=#0;
       end else begin
        RegularExpression^:=nil;
       end;
      finally
       s:='';
      end;
     end;
     result:=1;
    except
  