Delphi's wildcard comparison

zhaozj2021-02-16  45

DELPHI Comparison of wildcards: Lee Kwan Yu email: e271828@163.net or MSSQLserver2000@163.com or OKMYdelphi@163.net DELPHI features than VB strong is recognized, but in some small measure, but sometimes not as convenient VB, For example, SendKey () can be easily analog keyboard buttons in VB, but in Delphi, there is a relatively comparison of Like in VB to easily implement wildcard, but can't find it in Delphi, In the free state, I still have a custom function to make this feature when I have a mood, in order to prevent emergency, and I have no mood again. This kind of small program harness is useless, but it is better to make it A few points of light and heat. The program's algorithm first adds in the end of the substrings? * ', Reciprocation string, look up characters between wildcards in substrings, ie substrings in the subtrial strings, and then look for the substrings in the substring in the source string, but it is still very these charges trouble .function isABClikeAX (abc, ax: string): boolean; // abc is the source string, ax is a substring varabcstart, axstart, abclength, axlength: integer; endpartabc, endpartax, subax: string; temp, abcwww, axwww : integer; begin // aaatemp: = 0; abcstart: = 1; axstart: = 1; AXWW: = 1; abcww: = 1; abcww: = 1; Abclightth: = Length (ABC); Axlength: = Length (AX); isabclikeAx: = True; While AxStart <= AXLENGTH Do Begin // BBB IF AX [AxStart] = '?' Then Begin INC; INCSTART; if Abcstart> Abclength The Begin IsabclikeAx: = FALSE; End; if AX [axostart] = '*' TEN BEGIN INC; TEMP: = 1; AXWW: = AXStart; ABCww: = Abcstart; Continue; End; if NOT (AX [AxStart] in ['?', '*']) Then Begin // CCC Endpartax: = COPY (AX, AXSTART, AXLENGTH-AXSTART 1) '? *';

Subax: = COPY (Endpartax, 1, Min (POS ('?', endpartax), POS ('*', endpartax) - 1); axostart: = axstart min (POS ('?', endpartax), POS ('*', endpartax) - 1; endpartabc: = copy (abc, abcstart, abclength-abcstart 1); if ((Subax, EndpartAbc) <> 0) AND (TEMP = 1)) or ((Temp = 1)) OR POS (Subax, EndpartABC) = 1) And (Temp = 0)) THEN Begin // DDD IF TEMP = 1 Tens: = 0; Abcstart: = Abcstart (POS (Subax, EndpartAbc) Length (Subax) -1) ; // axostart: = axstart min (POS ('?', Endpartax), POS ('*', endpartax) - 1; end // ddd else // DDD begin // DDD IF TEMP = 0 THEN Begin AxStart : = AXww: = Abcwww 1; Abcstart: = Abcwww; Temp: = 1; Continue; End; IsabClikeAx: = false; Break; End; // DDD; // CCC end; // bbbend; // AAAFUNCTION ISLIKE (ABC, AX: String): Boolean; Begin Islike: = IsabClikeax (ABC, AX); End; Function WideCard (ABC, AX: String): Boolean; Begin WideCard: = IsabClikeax (ABC, AX); END;

Note Uses Math because of MIN (), you can use the IF statement to replace min (), but not enough.

转载请注明原文地址:https://www.9cbs.com/read-24534.html

New Post(0)