自制替换指定串函数

2016-01-29 14:09 2 1 收藏

自制替换指定串函数,自制替换指定串函数

【 tulaoshi.com - Delphi 】

 
这是本人自己制作的替换字符串中子串的函数,他可以从字符串中找出指定子串,并替换为另一子串。


            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;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/delphi/) 

来源:https://www.tulaoshi.com/n/20160129/1492665.html

延伸阅读
标签: Web开发
代码如下: Function DRexPage(Str) Dim RegEx If IsNull(Str) Or Str="" Then Exit Function Set RegEx=New RegExp RegEx.IgnoreCase=True RegEx.pattern="(\&)?page=(\d)+" DRexPage=regEx.replace(Str,"") '(Str,"$1") Set RegEx=Nothing End Function
标签: MySQL mysql数据库
  对于针对字符串位置的操作,第一个位置被标记为1。 ASCII(str) 返回字符串 str 的最左面字符的ASCII代码值。 如果 str 是空字符串,返回 0 。如果 str 是 NULL ,返回 NULL 。 mysql select ASCII('2'); - 50mysql select ASCII(2); - 50mysql select ASCII('dx'); - 100 也可参见ORD()函...
标签: Web开发
去掉字符串中匹配 的字符串 代码如下: /** * 去掉字符串中匹配 的字符串 * * @author zhujie * @return String regex 要替换的内容 value 字符串 state 替换的内容变成什么 */ public static String toRegex(String regex, String value, String state) { Pattern p = Pattern.compile(regex); Matcher m = p.matcher(value); String...
标签: 电脑入门
Excel中汇总统计符合指定条件单元格数据之和是经常遇到的事情。例如,统计学生的成绩表时,我们也许要在一张有多个班级多个学科的成绩总表中求某一指定班级某一学科学生的总分。这种情况我们一般使用SUMIF函数或SUM函数配合使用IF函数来完成汇总统计,如果指定的条件已经存放在另外的某单元格区域,那么在Excel 2007中,使用DSUM函数来完成指定...
标签: ASP
  '*************测字符串长度************** Function CheckStringLength(txt) txt=trim(txt) x = len(txt) y = 0 for ii = 1 to x if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) 255 then '如果是汉字 y = y + 2 else y = y + 1 end if next CheckStringLength = y End Function '************* 截取字符串 ************** f...

经验教程

313

收藏

10
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部