首部function RightStr(const AText: string; const ACount: Integer): string; $[StrUtils.pas
功能返回字符串AText右邊的ACount個字符
說明RightStr('123456', 3) = '456'
參考function System.Copy
例子Edit3.Text := RightStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function MidStr(const AText: string; const AStart, ACount: Integer): string; $[StrUtils.pas
功能返回字符串AText從AStart開始的ACount個字符
說明其實就是Copy
參考function System.Copy
例子Edit3.Text := MidStr(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SearchBuf(Buf: PChar; BufLen: Integer; SelStart, SelLength: Integer; SearchString: String; Options: TStringSearchOptions = [soDown]): PChar; $[StrUtils.pas
功能返回第一個搜索到的指針位置
說明這函數常用於文本中搜索字符串
參考<NULL>
例子
///////Begin SearchBuf
function SearchEdit(EditControl: TCustomEdit; const SearchString: String;
SearchOptions: TStringSearchOptions; FindFirst: Boolean = False): Boolean;
var
Buffer, P: PChar;
Size: Word;
begin
Result := False;
if (Length(SearchString) = 0) then Exit;
Size := EditControl.GetTextLen;
if (Size = 0) then Exit;
Buffer := StrAlloc(Size + 1);
try
EditControl.GetTextBuf(Buffer, Size + 1);
P := SearchBuf(Buffer, Size, EditControl.SelStart, EditControl.SelLength,
SearchString, SearchOptions);
if P <> nil then begin
EditControl.SelStart := P - Buffer;
EditControl.SelLength := Length(SearchString);
Result := True;
end;
finally
StrDispose(Buffer);
end;
end;
PRocedure TForm1.Button1Click(Sender: TObject);
var
SearchOptions: TStringSearchOptions;
begin
SearchOptions := [];
if CheckBox1.Checked then
Include(SearchOptions, soDown);
if CheckBox2.Checked then
Include(SearchOptions, soMatchCase);
if CheckBox3.Checked then
Include(SearchOptions, soWholeWord);
SearchEdit(Memo1, Edit1.Text, SearchOptions);
Memo1.SetFocus;
end;
///////End SearchBuf
━━━━━━━━━━━━━━━━━━━━━
首部function Soundex(const AText: string; ALength: TSoundexLength = 4): string; $[StrUtils.pas
功能返回探測字符串
說明根據探測法(Soundex)可以找到相進的字符串;http://www.nara.gov/genealogy/coding.Html
參考<NULL>
例子Edit2.Text := Soundex(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexInt(const AText: string; ALength: TSoundexIntLength = 4): Integer; $[StrUtils.pas
功能返回探測整數
說明ALength的值越大解碼準確率越高
參考<NULL>
例子SpinEdit2.Value := SoundexInt(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function DecodeSoundexInt(AValue: Integer): string; $[StrUtils.pas
功能返回探測整數的解碼
說明DecodeSoundexInt(SoundexInt('hello')) 相當於Soundex('hello')
參考<NULL>
例子Edit2.Text := DecodeSoundexInt(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexWord(const AText: string): Word; $[StrUtils.pas
功能返回探測文字數值
說明沒有參數ALength已經固定為4
參考<NULL>
例子SpinEdit2.Value := SoundexWord(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部function DecodeSoundexWord(AValue: Word): string; $[StrUtils.pas
功能返回探測文字數值的解碼
說明DecodeSoundexWord(SoundexWord('hello')) 相當於Soundex('hello')
參考<NULL>
例子Edit2.Text := DecodeSoundexWord(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexSimilar(const AText, AOther: string; ALength: TSoundexLength = 4): Boolean; $[StrUtils.pas
功能返回兩個字符串的探測字符串是否相同
說明Result := Soundex(AText, ALength) = Soundex(AOther, ALength)
參考<NULL>
例子CheckBox1.Checked := SoundexSimilar(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundexCompare(const AText, AOther: string; ALength: TSoundexLength = 4): Integer; $[StrUtils.pas
功能返回比較兩個字符串的探測字符串的結果
說明Result := AnsiCompareStr(Soundex(AText, ALength), Soundex(AOther, ALength))
參考function SysUtils.AnsiCompareStr
例子SpinEdit2.Value := SoundexCompare(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部function SoundeXProc(const AText, AOther: string): Boolean; $[StrUtils.pas
功能調用SoundexSimilar返回兩個字符串的探測字符串是否相同
說明系統變量AnsiResemblesProc的默認值
參考function StrUtils.AnsiResemblesText
例子[var AnsiResemblesProc: TCompareTextProc = SoundexProc;]