function LeftStr(S:string;Count:integer):string;
begin
//獲取字符串左邊起n個字符 LeftStr:=Copy(s,1,Count);
end;
function RightStr(S:string;Count:integer):string;
begin
//獲取字符串右邊起n個字符 RightStr:=Copy(s,Length(s)-Count+1,Count);
end;
function ReplaceStr(S:string;OldStr,NewStr:string):string;
var i,j:integer;
ss:string;
begin
//替換字符串 (其實Delphi已經提供對應的函數了StringReplace) i:=1;
ss:='';
j:=length(OldStr);
while i<=length(s) do
begin
if LowerCase(copy(s,i,j))=LowerCase(OldStr)
then
begin
ss:=ss+NewStr;
inc(i,j);
end
else
begin
ss:=ss+s[ i ];
inc(i,1);
end;
end;
Result:=ss;
end;
function LTrim(S:string):string;
begin
//刪除字符串左邊空格s:=s+'*';
s:=Trim(s);
Delete(s,length(s),1);
end;
function RTrim(S:string):string;
begin
//刪除字符串右邊空格s:='*'+s;
s:=Trim(s);
Delete(s,1,1);
end;
function LDelete(S,Sub:string):string;
begin
//刪除字符串左邊的某一所有字符while LeftStr(S,1)=sub do
Delete(S,1,1);
LDelete:=s;
end;
function RDelete(S,Sub:string):string;
begin
//刪除字符串右邊的某一所有字符sub:=copy(sub,1,1);
while RightStr(S,1)=sub do
Delete(S,length(s),1);
RDelete:=s;
end;
function MDelete(S,Sub:string):string;
begin
//刪除字符串中包含的某一所有字符sub:=copy(sub,1,1);
while Pos(sub,s)>0 do
Delete(S,Pos(sub,s),1);
MDelete:=s;
end;
function GetCodeNo(NoStr:string;NoLen:integer):string;
begin
//生成一個在數字前面自動補零編碼 NoStr:=Trim(NoStr);
Result:=copy('00000000000000000000',1,NoLen-length(NoStr))+NoStr;
end;