Wildcard Lookup function under Delphi

Source: Internet
Author: User
Tags copy lowercase

Wildcard Lookup function under Delphi

Function islike (Ax, abc:string): Boolean; Ax is a substring and ABC is a source string
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 does 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) <> 0) and (temp = 1)) Or (POS (Subax, ENDPARTABC) = 1) and (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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.