How to determine if a string matches a pattern (http://delphi.about.com/cs/adptips2003/a/bltip0203_3.htm?nl=1)
{ Usage: if IsLike('About Delphi', 'Abo?? Delp*') then ShowMessage('A match!') ; } uses SysUtils; function IsLike(AString, Pattern: string): boolean; var j, n, n1, n2: integer ; p1, p2: pchar ; label match, nomatch; begin AString := UpperCase(AString) ; Pattern := UpperCase(Pattern) ; n1 := Length(AString) ; n2 := Length(Pattern) ; if n1 < n2 then n := n1 else n := n2; p1 := pchar(AString) ; p2 := pchar(Pattern) ; for j := 1 to n do begin if p2^ = '*' then goto match; if (p2^ <> '?') and ( p2^ <> p1^ ) then goto nomatch; inc(p1) ; inc(p2) ; end; if n1> n2 then begin nomatch: Result := False; exit; end else if n1 < n2 then begin for j := n1 + 1 to n2 do begin if not ( p2^ in ['*','?'] ) then goto nomatch ; inc(p2) ; end; end; match: Result := True end; ~~~~~~~~~~~~~~~~~~~~~~~~~ Sds. ________________________________ To: delphi-br@yahoogrupos.com.br From: [EMAIL PROTECTED] Date: Tue, 7 Oct 2008 23:40:49 -0300 Subject: Re: [delphi-br] Similaridade entre duas Strings Caramba que se faz como hobby ? resolve problemas quanticos ???? heheheheh... []s Luiz Escobar ----- Original Message ----- From: Guionardo Furlan To: delphi-br@yahoogrupos.com.br Sent: Tuesday, October 07, 2008 10:13 PM Subject: Re: [delphi-br] Similaridade entre duas Strings .... PS: fiz isso depois da janta, e meio cansado. Provavelmente deve haver um algoritmo mais elaborado, usando redes neurais, ou até mesmo uma função do delphi que resolve a parada. Mas é legal pra gente queimar um pouco de fosfato fora dos problemas comuns. _________________________________________________________________ Confira vídeos com notícias do NY Times, gols direto do Lance, videocassetadas e muito mais no MSN Video! http://video.msn.com/?mkt=pt-br