Delphi学习:2个不错的通配符比较函数
作者 佚名技术
来源 互联网
浏览
发布时间 2012-01-18
|
|
//Continue testing next char...
Inc(aSource);
Inc(aPattern);
end;
'[': begin //Match given set of chars.
if (aPattern[1] in [#0,'[',']']) then
begin
//Invalid Set - So no match.
Result := False;
Exit;
end;
if (aPattern[1] = '^') then
begin
//Match for exclusion of given set...
Inc(aPattern, 2);
Result := True;
while (aPattern[0] <> ']') do
begin
if (aPattern[1] = '-') then
begin
//Match char exclusion range.
if (aSource[0] >= aPattern[0]) and (aSource[0] <= aPattern[2]) then
begin
//Given char failed set exclusion range.
Result := False;
Break;
end else
Inc(aPattern, 3);
end else
begin
//Match individual char exclusion.
if (aSource[0] = aPattern[0]) then
begin
//Given char failed set element exclusion.
Result := False;
Break;
end else
|
|
Inc(aPattern);
end;
end;
end else
begin
//Match for inclusion of given set...
Inc(aPattern);
Result := False;
while (aPattern[0] <> ']') do
begin
if (aPattern[1] = '-') then
begin
//Match char inclusion range.
if (aSource[0] >= aPattern[0]) and (aSource[0] <= aPattern[2]) then
begin
//Given char matched set range inclusion.
// Continue testing...
Result := True;
Break;
end else
Inc(aPattern, 3);
end else
begin
//Match individual char inclusion.
if (aSource[0] = aPattern[0]) then
begin
//Given char matched set element inclusion.
// Continue testing...
Result := True;
Break;
end else
Inc(aPattern);
end;
end;
end;
if (Result) then
begin
//Match was found. Continue further.
Inc(aSource);
//Position Pattern to char after "]"
|
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn
为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
|