在Delphi中解析包含变量名的字符串
发布时间:2020-12-15 09:42:35 所属栏目:大数据 来源:网络整理
导读:我正在编写一个应用程序,其中我有如下函数: var a,b,c,algorithm: stringbegina := some-operations-with-regular-expressions;b := some-other-operation-with-regular-expressions;c := just-similar-to-b-but-different;algorithm := IniFile.ReadString
我正在编写一个应用程序,其中我有如下函数:
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',''); algorithm := StringReplace(algorithm,'[<a>]',a,[]); algorithm := StringReplace(algorithm,'[<b>]','[<c>]',[]); DoDownload (algorithm,true); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |