Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[256] Like로 문자열 검색하기
civilian [civilian] 5839 읽음    2008-10-07 17:46

uses SysUtils;

function IsLike(AString, Pattern: string): boolean;
var
   j, n, n1, n2: integer ;
   p1, p2: pchar ;
label
   match, nomatch;
begin
   AString := UpperCase(AString) ;
   Pattern := UpperCase(Pattern) ;
   n1 := Length(AString) ;
   n2 := Length(Pattern) ;
   if n1 < n2 then n := n1 else n := n2;
   p1 := pchar(AString) ;
   p2 := pchar(Pattern) ;
   for j := 1 to n do begin
     if p2^ = '*' then goto match;
     if (p2^ <> '?') and ( p2^ <> p1^ ) then goto nomatch;
     inc(p1) ; inc(p2) ;
   end;
   if n1 > n2 then begin
nomatch: 
     Result := False;
     exit;
   end else if n1 < n2 then begin
     for j := n1 + 1 to n2 do begin
       if not ( p2^ in ['*','?'] ) then goto nomatch ;
       inc(p2) ;
     end;
   end;
match:
   Result := True 
end;



출처 : http://delphi.about.com

+ -

관련 글 리스트
256 Like로 문자열 검색하기 civilian 5839 2008/10/07
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.