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;

相关阅读 >>

Delphi2010:把stringgrid数据保存到excel

Delphi驱动方式winio模拟按键

Delphi工具之tdump

Delphi jpg图像加文字水印

Delphi 官方提供的六十多个firedac例子

Delphi 获取系统mydocuments文件夹路径

Delphi中获取光标句柄代码(包含获取当前线程id)

Delphi 拼接文件路径

Delphi reset 以只读方式打开文件

Delphi取得网页源码内容

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



打赏

取消

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

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

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

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

评论

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