Inno Setup中的通配符(测试固定字符串前缀后是否有任何值) [英] Wildcard characters in Inno Setup (test if there is any value after fixed string prefix)

查看:276
本文介绍了Inno Setup中的通配符(测试固定字符串前缀后是否有任何值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Inno Setup是否有一些通配符?我正在尝试遍历字符串,如果要搜索某个值,程序应返回1(我正在使用Pos()函数,该函数已经完成了我需要的操作),但是我的问题是该部分我要搜索的字符串不是静态的,因此我需要一些通配符,例如*,可以替换一个或多个字符.

Is there some wildcard characters for Inno Setup? I am trying to go through string and if there is some value that I'm searching for, the program should return 1 (I'm using Pos() function that already does what I need), but my problem here is that the part of string that I'm searching for is not static, so I need some wildcard character like * that can replace one or more characters.

推荐答案

Inno Setup Pascal脚本中没有模式匹配功能.

There's no pattern matching functionality in Inno Setup Pascal Script.

但是您可以使用如下函数:

But you can use a function like this:

function AnythingAfterPrefix(S: string; Prefix: string): Boolean;
begin
  Result := 
     (Copy(S, 1, Length(Prefix)) = Prefix) and
     (Length(S) > Length(Prefix));
end;

并像这样使用它:

if AnythingAfterPrefix(S, 'Listing connections...') then

您可能想添加 TrimRight 来忽略尾随空格:

You may want to add TrimRight to ignore trailing spaces:

if AnythingAfterPrefix(TrimRight(S), 'Listing connections...') then


类似的问题:


Similar questions:

  • Regular expression for string in Inno Setup
  • Basic email validation within Inno Setup script

这篇关于Inno Setup中的通配符(测试固定字符串前缀后是否有任何值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆