±ÍÇÏ´Â ¼Õ´Ô À̽ʴϴÙ
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ
  
  µ¨¸¶´ç °ø½Ä ÀºÇà°èÁÂ
  ÇϳªÀºÇà 227-910235-83607
  ¿¹±ÝÁÖ ÀÌ»ó±¹(¿î¿µÁø)
ÇÁ·ÎÁ§Æ® °Ô½ÃÆÇ
ÅõÇ¥°Ô½ÃÆÇ
µ¨¸¶´ç¼Ò°³
±âÃʺÎÅÍ È°¿ë±îÁö! µ¨ÆÄÀÌ ±³À° - µ¥ºê±â¾î
°­ÁÂ, ÆÁ, Á¤º¸ °­ÁÂ, ÆÁ, Á¤º¸ ÀÔ´Ï´Ù.
±Û³»¿ë - °­ÁÂ, ÆÁ, Á¤º¸
 [angel] ¹®ÀÚ¿­ ÆĽ̠ÇÔ¼ö
Ÿ¶ôõ»ç
(±è¼ºÈÆ)
2015-02-11 ¿ÀÀü 11:47:27
Ä«Å×°í¸®: ÆÁ
4388ȸ Á¶È¸



µî·ÏµÈ ÆÄÀÏÀÌ ¾ø½À´Ï´Ù.
¾È³çÇϼ¼¿ä. Å¸¶ôõ»ç ÀÔ´Ï´Ù.
µ¨ÆÄÀÌ ÀÔ¹®¼­°¡ ¾ø´Ù°í Çؼ­ ¾²°í Àִµ¥, ¾µ°Ô ¾ø¾î¼­ Á¦°¡ °³¹ßÇÑ ¶óÀ̺귯 Áß¿¡ Àִ ¹®ÀÚ¿­ ÆĽ̠ÇÔ¼ö ¿Ã¸³´Ï´Ù.

Delphi7, DelphiXE6, DelphiXE7, ¸ð¹ÙÀÏ ¿¡¼­ Å×½ºÆ® µÇ¾ú½À´Ï´Ù.


xyToken ÀÌ ÆĽ̠ÇÔ¼ö ÀÌ°í,

xySplit, xySplitName, xySplitValueÀº AText ¹®ÀÚ¿­À» ASub ±âÁØÀ¸·Î µÑ·Î ÂÉ°³´Â ÇÔ¼ö ÀÔ´Ï´Ù.


(example 1)

var
  i, nCnt: integer;
  MyList: TszString;
  sTest: string;
begin
  sTest := 'One'#1'Two'#1'Three'#1'Four';
  nCnt := xyToken(MyList, AText, #1);

  for i := 0 to nCnt - 1 do
     ShowMessage(MyList[i])
....

(example 2)
var
  MyList: TStringList;
  sTest: string;
begin
  sTest := 'One'#1'Two'#1'Three'#1'Four';
  MyList := TStringList.Create;
  MyList.Text := xyToken(AText, #1, #13#10);


(source)

type
  TszString = array of string;


function xyToken(var AList: TszString; const AText: string; const ASub: string): integer;
var
  i, nPast, nPos, nLen, nSub: integer;
begin
  integer(Result) := 0;
  nLen := Length(AText);
  nSub := Length(ASub);

  nPos := Pos(ASub, AText);
  nPast := 1;
  while nPos > 0 do
  begin
    if Result = Length(AList) then
      SetLength(AList, Result + 10);

    if nPos = nPast then
      AList[Result] := ''
    else
      AList[Result] := Copy(AText, nPast, nPos - nPast);
    Result := Result + 1;

    nPast := nPos + nSub;
    nPos := PosEx(ASub, AText, nPast);
  end;

  if nPast <= nLen then
  begin
    if Result = Length(AList) then
      SetLength(AList, Result + 1);
    AList[Result] := Copy(AText, nPast, MaxInt);
    Result := Result + 1;
  end;
end;

function xyToken(const AText: string; const ASub: string = #13#10;
  const ADelim: string = #13#10): string;
var
  i, nPast, nPos: integer;
begin
  Result := '';
  nPos := Pos(ASub, AText);
  while nPos > 0 do
  begin
    if nPos = nPast then
      Result := Result + ADelim
    else
      Result := Result + Copy(AText, nPast, nPos - nPast) + ADelim;
    nPast := nPos + 1;
    nPos := PosEx(ASub, AText, nPast);
  end;

  if nPast <= Length(AText) then
    Result := Result + Copy(AText, nPast, MaxInt) + ADelim;
end;


function xySplit(var AName, AValue: string; const AText, ASub: string): integer;
begin
  Result := Pos(ASub, AText);
  if Result < 1 then
  begin
    AName := AText;
    AValue := '';
  end
  else
  begin
    AName := Copy(AText, 1, Result - 1);
    AValue := Copy(AText, Result + Length(ASub), MaxInt);
  end;
end;

function xySplitName(const AText, ASub: string): string;
var
  nPos: integer;
begin
  nPos := Pos(ASub, AText);
  if nPos < 2 then
    Result :