Search code examples
inno-setuppascalscript

Wildcard characters in Inno Setup (test if there is any value after fixed string prefix)


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.


Solution

  • There was no pattern matching functionality in Inno Setup Pascal Script until recently. Since 6.1, you can use the WildcardMatch function (as the answer by @Roman shows).


    If you are stuck with an older version, or if you need a custom matching, 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;
    

    And use it like:

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

    You may want to add TrimRight to ignore trailing spaces:

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

    Similar questions: