function FastPosNoCase(
  const aSourceString, aFindString : String;
  const aSourceLen, aFindLen, StartPos : integer
  ) : integer;
var
  SourceLen : integer;
begin
  SourceLen := aSourceLen;
  SourceLen := SourceLen - aFindLen;
  if (StartPos-1) > SourceLen then begin
    Result := 0;
    Exit;
  end;
  SourceLen := SourceLen - StartPos;
  SourceLen := SourceLen +2;
  asm
    push ESI
    push EDI
    push EBX
    mov EDI, aSourceString
    add EDI, StartPos
    Dec EDI
    mov ESI, aFindString
    mov ECX, SourceLen
    Mov  Al, [ESI]
    // Make Al lowercase.
    and  Al, $df
    @ScaSB:
    Mov  Ah, [EDI]
    // Make Ah lowercase.
    and  Ah, $df
    cmp  Ah,Al
    jne  @NextChar
    @CompareStrings:
    mov  EBX, aFindLen
    dec  EBX    //add by ShengQuanhu
    Jz   @EndOfMatch
    //add end    @CompareNext:
    mov  Al, [ESI+EBX]
    mov  Ah, [EDI+EBX]
    // Make Al and Ah lowercase.
    and  Al, $df
    and  Ah, $df
    cmp  Al, Ah
    Jz   @Matches
    Mov  Al, [ESI]
    // Make Al lowercase.
    and  Al, $df
    Jmp  @NextChar
    @Matches:
    Dec  EBX
    Jnz  @CompareNext    //add by Shengquanhu
    @EndOfMatch:
    //add end    mov  EAX, EDI
    sub  EAX, aSourceString
    inc  EAX
    mov  Result, EAX
    jmp  @TheEnd
    @NextChar:
    Inc  EDI
    dec  ECX
    jnz  @ScaSB
    mov  Result,0
    @TheEnd:
    pop  EBX
    pop  EDI
    pop  ESI
  end;
end;

解决方案 »

  1.   

    汗颜哪,我写不出来!
    学习ing~~
      

  2.   

    kakaxixi_008(呵呵) 同志:您有何高见?
      

  3.   

    kakaxixi_008:我觉得有时候是有必要的,
    比如要是在一个很大的文本里查找某个字符~~效率就显得很重要了,我以前为此也很伤脑筋!
    不过现在计算机速度这么快,常规的字符搜索就没有必要这样了,还是用用delphi的函数比较省事!
      

  4.   

    算法最重要!!!!高手就高在这里!!!感谢 forgot2000(忘记2000年)同志!!!