anchor.diff:       continue;
       end;
       opBOL:begin
  -     if (Position=0) or ((Position>0) and (Input[Position-1] in [#10,#13])) then begin
  +     if rfUTF8 in Flags then begin
  +      OtherPosition:=Position;
  +      UTF8PtrDec(ThreadLocalState.Input,ThreadLocalState.InputLength,OtherPosition);
  +     end else begin
  +      OtherPosition:=Position-1;
  +     end;
  +     if Position<0 then begin
         Instruction:=Instruction^.Next;
         continue;
        end else begin
  +      if rfUTF8 in Flags then begin
  +       CurrentChar:=UTF8PtrCodeUnitGetChar(ThreadLocalState.Input,ThreadLocalState.InputLength,OtherPosition);
  +       case CurrentChar of
  +        $0a,$0c,$0d,$85,$2028,$2029:begin
  +         Instruction:=Instruction^.Next;
  +         continue;
  +        end;
  +       end;
  +      end else begin
  +       case ThreadLocalState.Input[OtherPosition] of
  +        #10,#13:begin
  +         Instruction:=Instruction^.Next;
  +         continue;
  +        end;
  +       end;
  +      end;
         DecRef(SubMatches);
         break;
        end;
       end;
       opEOL:begin
  -     if ((Position+1)>=InputLength) or (((Position+1)<InputLength) and (Input[Position+1] in [#10,#13])) then begin
  +     if rfUTF8 in Flags then begin
  +      OtherPosition:=Position;
  +      UTF8PtrSafeInc(ThreadLocalState.Input,ThreadLocalState.InputLength,OtherPosition);
  +     end else begin
  +      OtherPosition:=Position+1;
  +     end;
  +     if OtherPosition>=ThreadLocalState.InputLength then begin
         Instruction:=Instruction^.Next;
         continue;
        end else begin
  +      if rfUTF8 in Flags then begin
  +       CurrentChar:=UTF8PtrCodeUnitGetChar(ThreadLocalState.Input,ThreadLocalState.InputLength,OtherPosition);
  +       case CurrentChar of
  +        $0a,$0c,$0d,$85,$2028,$2029:begin
  +         Instruction:=Instruction^.Next;
  +         continue;
  +        end;
  +       end;
  +      end else begin
  +       case ThreadLocalState.Input[OtherPosition] of
  +        #10,#13:begin
  +         Instruction:=Instruction^.Next;
  +         continue;
  +        end;
  +       end;
  +      end;
         DecRef(SubMatches);
         break;
        end;
  
positive.code:     CurrentChar:ansichar;
      Capture:PFLRECapture;
      BitState:longword;
      LocalInput:pansichar;
  begin
   result:=false;
  
   LocalInput:=Input;
  
   CurrentThreadList:=@ThreadLists[0];
   NewThreadList:=@ThreadLists[1];
  
negative.code:               i:=j;
               end else begin
                if (e>=0) and (e<length(Captures)) then begin
                 result:=result+PtrCopy(PAnsiChar(Input),Captures[e].Start,Captures[e].Length);
                end;
               end;
              end else begin
  