Sometimes we need to know if a string matches a pattern, which is a string with wildcards (for example "?" and "*"). Here we implement a function that returns True if the string matches the pattern and False if not.
function Like(AString, Pattern: string): boolean;
i, n, n1, n2: integer;
p1, p2: pchar;
AString := UpperCase(AString);
Pattern := UpperCase(Pattern);
n1 := Length(AString);
n2 := Length(Pattern);
if n1 p1 := pchar(AString);
p2 := pchar(Pattern);
for i := 1 to n do begin
if p2^ = "*" then goto match;
if (p2^ "?") and (p2^ p1^) then goto nomatch;
if n1 n2 then begin
Result := False;
end else if n1 for i := n1 + 1 to n2 do begin
if not (p2^ in ["*","?"]) then goto nomatch;
Result := True;
if Like("Walter", "WA?T*") then
A portal that has dedication and concentration in the development of computer programming and more
resource for help people such as open project, jobs, question & answer, additional tools, and many more.
Collection of various kinds of code programming language from desktop to web programming.