Reputation: 71
In Inno Setup tool (Windows OS)
InstallDir: string;
I have a string InstallDir
which contains C:\-=[]\.,';
I want to set a regular expression pattern as below
^([a-zA-Z]:)\\([0-9a-zA-Z_\\\s\.\-\(\)]*)$
Ex:
It should be c:\
< A
to Z
/ a
to z
> or number or _
and so on (means a valid path).
I could not find any function in Inno Setup, which tells it supports regular expression for string operations.
Can any body help me out to resolve this?
Upvotes: 6
Views: 2684
Reputation: 202474
No, Inno Setup does not support regular expressions.
You may be able to invoke PowerShell for that, but that's an overkill.
You do not need a regular expression for your check:
function IsPathValid(Path: string): Boolean;
var
I: Integer;
begin
Path := Uppercase(Path);
Result :=
(Length(Path) >= 3) and
(Path[1] >= 'A') and (Path[1] <= 'Z') and
(Path[2] = ':') and
(Path[3] = '\');
if Result then
begin
for I := 3 to Length(Path) do
begin
case Path[I] of
'0'..'9', 'A'..'Z', '\', ' ', '.', '-', '(', ')':
else
begin
Result := False;
Break;
end;
end;
end;
end;
end;
(The code requires Unicode version of Inno Setup, what you should use anyway and it is the only version as of current Inno Setup 6).
Similar questions:
Upvotes: 6