String Delphi

Title: String Pattern Matching(Third Edition)
Question: String Pattern Matching(Third Edition)
Answer:
String Pattern Matching(Fourth Edition)
The like function take 2 strings and compare them using simple pattern matching. Only '*' and '?' are implemented, range syntaxe '[]' are not implemented.
Exemple : like('abcdxabcdxabcdefg', '*abcd?abcdefg*') = true,
like('abaababcac', '*abaabcac*') = false , etc...
Maybe this is faster than the MathesMask function and the another recursive function which is tranabclengthated from MatchPattern() of common.c in MSDN Samplax\VC98\sdk\sdktools\tlist . The first edition islike() use the KMP arithmetic.The fourth edition like() does not use the KMP arithmetic,but the like() faster than the islike().After have try it many times I found that maybe the like() is the fastest function which is String Pattern Matching I meet.
Function like (const abc, ax:string) :boolean;//abc is source string,ax is substring
Var
axlenth,abclength,abci,axi, cur_star_pos,abci2,axi2:integer;
abcchar,axchar:char;
Begin//aaa
like:= true;
axlenth:=length(ax);
abclength:=length(abc);
abci:=1;//abc index
axi:=1;//ax index
cur_star_pos:=-1; //current star sign position
while ((abci begin //bbb
abcchar:=abc[abci];
axchar:=ax[axi];
if ((abcchar='*') or (abcchar='?') or (abccharaxchar)) then
begin//ccc
if(axchar='*') then begin //xxx
cur_star_pos:=axi; axi:=axi+1;
end//xxx
else
begin //xxx
if(axchar= '?') then
begin
abci:=abci+1;
inc(axi);
end
else
begin//www
if(cur_star_pos=1) then begin //ttt
while(axicur_star_pos) do begin //sss
axchar:=ax[axi];
if(axchar=abcchar) or (axchar='?') then
begin//eeeeeeeeeeee
abci2:=abci;axi2:=axi;while(axi2cur_star_pos)do begin
if (ax[axi2]=abc[abci2] ) or (ax[axi2]= '?') then begin
axi2:=axi2-1;abci2:=abci2-1;
end
else
break;
end;
if axi2= cur_star_pos then break;
end;//eeeeeeeeeeee
axi:=axi-1;
if(axi=cur_star_pos) then
begin
inc(abci);
end;end;//sss
end//ttt
else//ttt
begin//ttt
like:=false; break;
end;//ttt
end;//www
end;//xxx
end//ccc
else
begin
inc(abci); inc(axi);
end; //ccc
end;//bbb
if (result=true)and (abciabclength) and(axiif (result=true)and (abciaxlenth) and (ax[axlenth]'*') then result:=false;
end;//aaa
Author:Li.JunYu,also named Bill.Building.SunShine,a chinese,
Email: e271828@163.net,MsSqlServer2000@163.com
================================================================