Title: Compare Strings with wildcards
Question: Howto Compare Strings with wildcards for Characters
Answer:
unit compString;
interface
Function CompStr( Stra, Valcode : String) : Boolean;
implementation
function CompStr( Stra, Valcode : String) : Boolean;
var K : integer;
Procedure CompChar(a,v : char);
var i, code : integer;
begin
case v of
'?':begin
val(a,i,code);
if code = 0 then CompStr := False;
end;
'#':begin
val(a,i,code);
if code = 1 then CompStr := False;
end;
'*':
else begin
if a v then CompStr := False;
end;
end;
end;
begin
if length(Stra) = Length(Valcode)
then
begin
CompStr := True;
For k := 1 to Length(StrA) do
begin
CompChar(Stra[k],Valcode[k]);
if not(result) then break;
end;
end
Else Result := False;
end;
end.