請問有何function可以傳回子字串在主字串中的第幾個位置 |
答題得分者是:wameng
|
energybody
一般會員 ![]() ![]() 發表:44 回覆:32 積分:15 註冊:2007-04-12 發送簡訊給我 |
|
pedro
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:152 回覆:1187 積分:892 註冊:2002-06-12 發送簡訊給我 |
|
wameng
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
function FastPos(const Substr, S :String;Index :Integer):Integer;
function FastmemPos(const aSource, aFind; const aSourceLen, aFindLen : integer) : Pointer; asm push ESI push EDI push EBX mov ESI, aFind mov EDI, aSource mov ECX, aSourceLen mov Result, 0 cmp ECX, aFindLen jl @TheEnd cmp aFindLen, 1 jl @TheEnd sub ECX, aFindLen inc ECX Mov Al, [ESI] jmp @Scasb @FindNext: inc EDI dec ECX jz @NotFound @ScaSB: cmp [EDI], al jz @CompareStrings inc EDI dec ECX jnz @ScaSB jmp @NotFound @CompareStrings: mov EBX, aFindLen @CompareNext: dec EBX jz @FullMatch mov Ah, [ESI EBX] cmp Ah, [EDI EBX] Jnz @FindNext Jmp @CompareNext @FullMatch: mov Result, EDI jmp @TheEnd @NotFound: mov Result, 0 @TheEnd: pop EBX pop EDI pop ESI end; begin if Index<1 then Index := 1; Result := Integer(FastmemPos(S[Index], Substr[1],Length(S) - (Index -1),Length(SubStr))); if Result>0 then Result := Result - Integer(@S[1]) 1; end; |
energybody
一般會員 ![]() ![]() 發表:44 回覆:32 積分:15 註冊:2007-04-12 發送簡訊給我 |
|
energybody
一般會員 ![]() ![]() 發表:44 回覆:32 積分:15 註冊:2007-04-12 發送簡訊給我 |
|
taishyang
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
沒有搞錯吧? 選缺席表示沒有人的答案符合你的需求,是這樣嗎?
結案的方式: 結案的按鈕左邊有一個ComboBox,選擇答題得分者在按下結案按鈕即可 ===================引 用 energybody 文 章=================== 回覆 站務副站長, 小弟已按 將此問題結案 及選擇 缺席, 但是不能結案, 能否請 副站長 幫忙結案. |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |