gpt4 book ai didi

string - 在Delphi中解析包含变量名称的字符串

转载 作者:行者123 更新时间:2023-12-03 15:16:50 25 4
gpt4 key购买 nike

我目前正在编写一个应用程序,其中的函数如下:

var a,b,c, algorithm: string
begin

a := some-operations-with-regular-expressions;
b := some-other-operation-with-regular-expressions;
c := just-similar-to-b-but-different;

algorithm := IniFile.ReadString('XML Info','AlgorithmExpression', '');
//algorithm is fetched like 'http://wwww.urlhere' + a + '/' + b + '/' + c
DoDownload (algorithm, true);
end;

现在我期望的是 a、b 和 c 自动替换为同名变量的值,但看来我错了。有没有办法得到由 '' 和变量值之间的字符串组成的算法变量的结果?

任何建议(即使需要重大重新设计)将不胜感激。

谢谢,斯芬克斯

最佳答案

我不明白你想做什么,但这里有一个镜头。

IniFile 应该包含如下内容:

[XML Info]
AlgorithmExpression=http://wwww.urlhere[<a>]/[<b>]/[<c>]

你可以这样做:

algorithm := IniFile.ReadString('XML Info','AlgorithmExpression', ''); 
algorithm := StringReplace(algorithm,'[<a>]',a,[]);
algorithm := StringReplace(algorithm,'[<b>]',b,[]);
algorithm := StringReplace(algorithm,'[<c>]',c,[]);
DoDownload (algorithm, true);

关于string - 在Delphi中解析包含变量名称的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8418567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com