DeeJay007
DeeJay007

Reputation: 509

Inno setup how to check if a string contains at least one special character

I am writing script to check if my password string contains at least one special character in it. I learned regex is not possible with InnoSetup.

Could someone help me in achieving this?

Thanks in Advance,

DeeJay

Upvotes: 1

Views: 1712

Answers (1)

Wosi
Wosi

Reputation: 45293

[code]
function PasswordContainsAtLeastOneSpecialChar(Pass : String) : Boolean;
var
    i : integer;
begin
    Result := false;

    for i:=1 to length(Pass) do
    begin
        case Pass[i] of
          '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '\', '*', '#': // list all special characters here 
          begin
            Result := true;
            Exit;
          end;
        end;
    end;                           
end;

Upvotes: 6

Related Questions