Delphi 下的通配符查找函数

//Delphi 下的通配符查找函数
Function
 IsLike(ax, abc: String): Boolean; //ax是子串,abc是源串 Var   abcstart, axstart, abclength, axlength: Integer;   endpartabc, endpartax, subax: String;   temp, abcwww, axwww: Integer; Begin //aaa   temp := 0;   abcstart := 1;   axstart := 1;   axwww := 1;   abcwww := 1;   ax:=LowerCase(ax);   abc:=LowerCase(abc);   abclength := Length(abc);   axlength := Length(ax);   result := True;   While axstart <= axlength Do Begin //bbb     If ax[axstart] = '?' Then Begin       inc(axstart);       inc(abcstart);       If abcstart > abclength+1 Then Begin         result := false;         Break;       End;       Continue;     End;     If ax[axstart] = '*' Then Begin       inc(axstart);       temp := 1;       axwww := axstart;       abcwww := abcstart;       Continue;     End;     If Not (ax[axstart] In ['?''*']) Then Begin //ccc       endpartax := Copy(ax, axstart, axlength - axstart + 1) + '?*';       If Pos('?', endpartax) < Pos('*', endpartax) Then Begin         subax := Copy(endpartax, 1, Pos('?', endpartax) - 1);         axstart := axstart + Pos('?', endpartax) - 1;       End       Else Begin         subax := Copy(endpartax, 1, Pos('*', endpartax) - 1);         axstart := axstart + Pos('*', endpartax) - 1;       End;       endpartabc := Copy(abc, abcstart, abclength - abcstart + 1);       If ((Pos(subax, endpartabc) <> 0And (temp = 1)) Or ((Pos(subax, endpartabc) = 1And (temp = 0)) Then Begin //ddd         If temp = 1 Then temp := 0;         abcstart := abcstart + (Pos(subax, endpartabc) + Length(subax) - 1);       End       Else  Begin //ddd         If temp = 0 Then Begin           axstart := axwww;           abcwww := abcwww + 1;           abcstart := abcwww;           temp := 1;           Continue;         End;         result := false;         Break;       End//ddd     End//ccc   End//bbb End//aaa

转载于:https://www.cnblogs.com/tulater/archive/2008/10/23/1317436.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值