Delphi 根据开始和结束符取得中间字符串


本文整理自网络,侵删。

 
// 根据开始和结束符取得中间字符串
function CenterStr(const strSrc : String; const strBegin : String; const strEnd : String) : String;
var
    iPosBegin, iPosEnd: integer;
    strSrcLow, strBeginLow, strEndLow: String;
begin
    strSrcLow := LowerCase(strSrc);
    strBeginLow := LowerCase(strBegin);
    strEndLow := LowerCase(strEnd);

    iPosBegin := Pos(strBeginLow, strSrcLow) + Length(strBeginLow);
    iPosEnd := Pos(strEndLow, strSrcLow);

    result := Copy(strSrc, iPosBegin, iPosEnd - iPosBegin);
end;


增强功能
// 获取配置值
function GetConfigValue(const strSrc : string; strConfigName: string): string;
begin
    result := CenterStr(strSrc, '<' + strConfigName + '>', '<' + strConfigName + '>'); 
end;

相关阅读 >>

Delphi 简单的登录窗口

Delphi sysutils.strcat

Delphi fastreport快速入门

Delphi中判断一个字符的位置在字符串开头或者末尾

Delphi - system.runerror

Delphi windows api判断文件共享锁定状态

Delphi使用文件拖放功能

Delphi 根据文件路径获取文件名

Delphi xe tparallel.for的用法

Delphi android windows ios通用获取程序版本

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...