2

Delphi を使用して、特定の文字列の後に続くメモ フィールドからデータを削除するにはどうすればよいでしょうか。たとえば、データベース内のデータは次のように表示されます。

<Data I want to keep>

======= Old Data ========
<line 1>
<line 2>
etc.

古いデータ行の後 (およびそれを含む) のすべてのデータを削除するように Delphi に指示するにはどうすればよいですか? しかし、私が保持したいデータに触れませんか?

4

2 に答える 2

7

何かのようなもの:

var
  I: Integer;
  s: string;
begin
  s := 'your big string with ======= Old Data ======== and more';
  I:=Pos('======= Old Data ========',s);
  if I>0 then
    Delete(s, I, MaxInt);
  ShowMessage(s);
于 2012-04-06T22:36:29.097 に答える
1

これを試して:

procedure myForm.ClearFromLine(value: string);
var
  i, index: integer;
begin
  index := memo.lines.IndexOf(value);
  if index = -1 then
    Exit;
  memo.lines.BeginUpdate;
  try
    for i := memo.lines.count - 1 downto index do
      memo.lines.delete(i);
  finally
    memo.lines.EndUpdate;
  end;
end;
于 2012-04-06T22:44:21.527 に答える