Autor Beitrag
acnut
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Sa 22.05.10 12:31 
ich will von einer txt datei wo eine emailliste vorhanden ist unnötige stellen löschen.
genauer gesagt will ich <address><![CDATA[ löschen.
wie realisiere ich das?
hab das mit delete probiert, diese löscht aber die ganze txt datei!


mfg
acnut
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Sa 22.05.10 12:38 
Du müsstest das Dokument Zeile für Zeile durchgehen und diese dann Parsen, hier mal ein Link zur Hilfe www.delphibasics.co.uk/RTL.asp?Name=Pos.

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Sa 22.05.10 12:47 
so hab ich das gemacht, und das funktioniert nicht
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  i: integer;
  Line: string;
begin
  for i := 0 to Memo1.Lines.Count - 1 do begin
    Line := Memo1.Lines[i]; 
     delete(Line, 1, 18);


warum brauch ich pos, warum gehtdas nicht nur mit delete?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 22.05.10 13:02 
Hallo,

du musst natürlich den bearbeiteten String aus der Variablen Line wieder in das Memo zurückschreiben.

Wenn immer die ersten 18 Zeichen gelöscht werden sollen, brauchst du kein Pos.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Sa 22.05.10 13:05 
user profile iconacnut hat folgendes geschrieben Zum zitierten Posting springen:

warum brauch ich pos, warum gehtdas nicht nur mit delete?


Wenn der zu löschende String immer am Anfang einer Zeile ist dann brauchst du natürlich kein Pos wie user profile iconLannes bereits erwähnte.

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
StrikeLucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Sa 22.05.10 13:10 
Warum kein StringReplace?
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Sa 22.05.10 13:13 
danke für eure antworten aber es geht immer noch nicht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  i: integer;
  Line: string;
begin
memo1.clear;
  memo1.Lines.LoadFromFile('D:\Delphi\EmailXML\export.txt');

  for i := 0 to Memo1.Lines.Count - 1 do begin
    Line := Memo1.Lines[i];
     delete(Line, 1, 18);
     Memo1.text:=line;

-->so sehe ich leider gar nichts


user profile iconStrikeLucky hat folgendes geschrieben Zum zitierten Posting springen:
Warum kein StringReplace?


das hab ich am anfang probiert, aber das hat bei mir gar nichts bewirkt.
so hatte ich das am anfang gemacht:
ausblenden Delphi-Quelltext
1:
2:
  StringReplace(line, '<address><![CDATA', '', [rfReplaceAll]);
memo1.text:=line;


mfg
acnut
StrikeLucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Sa 22.05.10 13:26 
Zwischen "<address>" und "<![CDATA" befindet sich die Email oder?
Dann müsstest du erstmal "<address>" mit nichts ersetzen und danach dann "<![CDATA" mit nichts ersetzen.
Kannst ja mal einen kleinen Ausschnitt aus deiner Datei zeigen.
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Sa 22.05.10 13:28 
nein nein, die emailadresse befindet sich nach <address><![CDATA[

bsp:
<address><![CDATA[abd5812@hotmail.com]]></address>
mfg
StrikeLucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Sa 22.05.10 13:56 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
var
  a, b: TStringList;
  i: Integer;
  s: String;
begin
  if OpenDialog1.Execute then
  begin
    a := TStringList.Create;
    b := TStringList.Create;

    try
      a.LoadFromFile(OpenDialog1.FileName);

      for i := 0 to a.Count - 1 do
      begin
        s := a.Strings[i];
        s := StringReplace(s, '<address><![CDATA[', '', []);
        s := StringReplace(s, ']]></address>', '', []);
        b.Add(s);
      end;

      b.SaveToFile(ExtractFilePath(ParamStr(0)) + 'Liste2.txt');
    finally
      a.Free;
      b.Free;
    end;
  end;
end;


So funktioniert das schonmal ganz gut:)
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: Sa 22.05.10 15:33 
vielen dank, code funktioniert einwandfrei:)

aber es würde mich trotzdem interesiieren warum das mit meinem code nicht funktioniert hat



mfg
StrikeLucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Sa 22.05.10 16:46 
Ich denk mal du hättest das so machen müssen.
ausblenden Delphi-Quelltext
1:
line := StringReplace(line, '<address><![CDATA', '', [rfReplaceAll]);					
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 22.05.10 23:21 
user profile iconacnut hat folgendes geschrieben Zum zitierten Posting springen:
aber es würde mich trotzdem interesiieren warum das mit meinem code nicht funktioniert hat
Weil du die erste Zeile ausliest (Line := Memo1.Lines[i];), bearbeitest und dann den ganzen Text des Memos damit überschreibst (Memo1.text:=line;). Dann hast du keine weiteren Zeilen mehr...
acnut Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 172
Erhaltene Danke: 3

Windows 7, Windows Vista, Windows XP, Ubuntu, Kubuntu, Pardus
Delphi 2010 SV, Java Editor, VS 2010 SV
BeitragVerfasst: So 23.05.10 09:24 
achso ok danke


mfg