まず検索関数から
//高速版 AnsiStrPos
function AnsiStrPosEx(StrStart, StrEnd, SubStrStart, SubStrEnd: PChar): PChar;
var
 p, ps: PChar;
 SL  : Integer;
begin
 p := StrStart;
 SL := SubStrEnd-SubStrStart;
 Result := Nil;
 while p < StrEnd do
 begin
  ps := SubStrStart;
  while ps^ = p^ do
  begin
   Inc(p);  Inc(ps);
   if ps^ = #0 then
   begin
    Dec(p,SL);
    Result := p;
    Exit;
   end;
  end;
  if p^ in [#$81..#$9F, #$E0..#$FC] then Inc(p);
  Inc(p);
 end;
 Result := Nil;
end;