| // =========================== // Function 1 // =========================== // Check if the string can match the wildcard. It can be used for unicode strings as well! // C: 2004-07-24 | M: 2004-07-24 function MaskMatch(const aPattern, aSource: string): Boolean; var StringPtr, PatternPtr: PChar; StringRes, PatternRes: PChar; begin Result := False; StringPtr := PChar(UpperCase(aSource)); PatternPtr := PChar(UpperCase(aPattern)); StringRes := nil; PatternRes := nil; repeat repeat // ohne vorangegangenes "*" case PatternPtr^ of #0 : begin Result := StringPtr^ = #0; if Result or (StringRes = nil) or (PatternRes = nil) then Exit; StringPtr := StringRes; PatternPtr := PatternRes; Break; end; '*': begin Inc(PatternPtr); PatternRes := PatternPtr; Break; end; '?': begin if StringPtr^ = #0 then Exit; Inc(StringPtr); Inc(PatternPtr); end; else begin if StringPtr^ = #0 then Exit; if StringPtr^ <> PatternPtr^ then begin if (StringRes = nil) or (PatternRes = nil) then Exit; StringPtr := StringRes; PatternPtr := PatternRes; |