StrScan : 返回一个字符在一个 PChar 串中第一次出现的位置指针;
StrRScan : 返回一个字符在一个 PChar 串中最后一次出现的位置指针;
StrPos : 返回一个 PChar 串在另一个 PChar 串中第一次出现的位置指针.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//StrScan、StrRScan:
procedure TForm1.Button1Click(Sender: TObject);
var
p: PChar;
str: string;
begin
str := 'ABCBBBCBA';
p := StrScan(PChar(str), 'B');
ShowMessage(p); {BCBBBCBA}
p := StrRScan(PChar(str), 'B');
ShowMessage(p); {BA}
end;
//StrPos:
procedure TForm1.Button2Click(Sender: TObject);
var
p: PChar;
str: string;
begin
str := '123456789';
p := StrPos(PChar(str), '456');
ShowMessage(p); {456789}
end;
end.
SysUtils 单元下的公用函数目录