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 调用api.ocr.space的ocr接口

Delphi 如何把字符串覆给数组

Delphi数值转ip

Delphi 从dbgird中导出到excel

Delphi 取控件下的图象

Delphi如何实现模拟组合按键,如发送ctrl_f的按键消息

Delphi开发linux的动态库

Delphi winapi: getforegroundwindow - 获取前台窗口的句柄

Delphi结构体的方法

Delphi utf-8

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



打赏

取消

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

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

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

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

评论

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