unit CutStr;
interface
uses Classes;
type
wd = record
a : String;
b : String;
c : String;
end;
function cutin(StrSource,StrBegin,StrEnd:string):string;
function cutout(StrSource,StrBegin,StrEnd:string):string;
function cutStoI(StrSource,StrBegin:string;i:integer):string;
function namedd:string;
function CutBody(StrSource,fg,StrBegin,StrEnd:string):TStringList;
function StrRep(StrSource:string):string;
function FunTwo(InStr :string) :wd; //返回记录
implementation
uses SysUtils;
function FunTwo(InStr :string) :wd; //返回记录
var tempRec :wd;
begin
tempRec.a := 'x';
tempRec.b := 'y';
tempRec.c := 'z';
result := tempRec;
end;
function namedd:string;
begin
Result:=cutin('12345阿斯蒂芬67890','345','678');
end;
function cutin(StrSource,StrBegin,StrEnd:string):string;
var
i_star,i_end:integer;
begin
i_star:=AnsiPos(StrBegin,strsource);//-length(strbegin);
i_end:=AnsiPos(StrEnd,StrSource)+length(StrEnd);
result:=copy(StrSource,i_star,i_end-i_star);
end;
function cutout(StrSource,StrBegin,StrEnd:string):string;
var
i_star,i_end:integer;
begin
i_star:=AnsiPos(StrBegin,strsource)+length(strbegin);
i_end:=AnsiPos(StrEnd,StrSource);
result:=copy(StrSource,i_star,i_end-i_star);
end;
function cutStoI(StrSource,StrBegin:string;i:integer):string;
var
i_star,i_end:integer;
begin
i_star:=AnsiPos(StrBegin,strsource);
result:=copy(StrSource,i_star,i);
end;
function StrRep(StrSource:string):string;
var
s:string;
begin
s := Trim(StrSource);
s := StringReplace(s, ' ', '', [rfReplaceAll]);
s := StringReplace(s, #13, '', [rfReplaceAll]);
s := StringReplace(s, #10, '', [rfReplaceAll]);
Result:=s;
end;
function CutBody(StrSource,fg,StrBegin,StrEnd:string):TStringList;
var
i: Integer;
StrBody,key,keyall:string;
list:TStringList;
begin
LIST:=TStringList.Create;
keyall:='';
while Pos(fg, StrSource) > 0 do
begin
i := Pos(fg, StrSource)+length(fg);
key := cutout(StrSource,StrBegin,StrEnd);
list.Add(key);
StrSource := Copy(StrSource, i, Length(StrSource));
end;
Result:=list;
//list1.Free;
end;
end.