当前位置: 首页 > 图文教程 > 开发语言 > Delphi > 替换指定串函数

Delphi
文件管理(一)
文件管理(二)
文件管理(三)
剪贴板和动态数据交换(一)
剪贴板和动态数据交换(二)
对象链接与嵌入(一)
对象链接与嵌入(二)
Delphi拖放编程
动态链接库编程(一)
Delphi 应用编程实例简介
在Delphi应用程序中使用DLL
Delphi中API编程--在Delphi中调用API函数
如何在Delphi中制作“动态选单”
用Delphi编制金额大写转换程序
用Delphi制作Windows 98风格的工具栏
用Delphi检测特殊键状态
创建“控制面板”的新项目
用Delphi实现文件关联
Delphi使用三则
用Delphi制作“复活节彩蛋”

Delphi 中的 替换指定串函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 103 ::
收藏到网摘: n/a

 

一个替换指定串的函数,从一个字符串中找出指定子串,并替换为另一子串。
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;