当前位置:主页>仓库管理软件> 列表

求替换字符串函数 找财务软件

记账软件版1楼: 如把''abcdefg123aabb''中的''aabb''替换为''AB'',最后为''abcdefg123AB'',有什么函数

2楼: V1:= StringReplace(''abcdefg123aabb'', ''aabb'', ''AB'', [rfReplaceAll]); 如财务软件

3楼: 替换字符串中子串的函数,他可以从字符串中找出指定子串,并替换为另一子串。
function replacing(S,source,target:string):string;
var site,StrLen:integer;
begin
{source在S中出现的位置}
site:=pos(source,s);

{source的长度}
StrLen:=length(source);

{删除source字符串}
delete(s,site,StrLen);

{插入target字符串到S中}
insert(target,s,site);

{返回新串}
replacing:=s;
end;
///////////////////////
另两个替换字符串中子串的函数
function repl_substr( sub1, sub2, s: string ): string;
var i: integer;
begin
repeat
i := pos( sub1, s ) ;
if i > 0 then begin
delete( s, i, Length(sub1));
insert( sub2, s, i );
end;


until i < 1;
Result := s;
end;

function ReplaceText(const S,ReplacePiece,ReplaceWith: String):String;

Var Position: Integer;
TempStr: String;
begin
Position := Pos(ReplacePiece,S);
if Position > 0 then Begin
TempStr := S;
Delete(TempStr,1,Position-1+Length(ReplacePiece));
Result :=
Copy(S,1,Position-1)+ReplaceWith+ReplaceText(TempStr,ReplacePiece,ReplaceWith)

End else Result := S;
end;

4楼: 收藏。

5楼: 记得给分啊!

6楼: 多人接受答案了。