Autor Beitrag
rabby
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

gentoo

BeitragVerfasst: Sa 06.11.04 15:31 
hallo welt !
hab leider ein kleines parser problem, was ich nun gern mal mit delphi lösen würde.
wie jeder erkennen wird, handelt es sich um html code, der verarbeitet werden muss.
ausgangssituation:
ausblenden Quelltext
1:
...<a evt_unwichtige_tags_vor_href http://site1... ...irgendwelche andren tags danach>...<a ...noch viele mehr...>					

danach soll sowas rauskommen:
ausblenden Quelltext
1:
...http://site1:<a evt_unwichtige_tags_vor_href href=http://site1... ...irgendwelche andren tags danach>...http://site2:<a href=http://site2...noch viele mehr...>					


die reihenfolge innerhalb der <a> tags ist unregelmäßig und die href eigenschaften sind nicht durch " umschlossen, sondern gehen von href= bis zum nächsten leerzeichen.

bitte um hilfe!
vielen dank...
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 06.11.04 15:37 
In etwa so würde ichs machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  s, zeile : string;
begin
  a:=Pos('<a ',zeile);
  s:=Copy(zeile,a,Pos('>',zeile)-a);
  s:=Copy(s,Pos('href=')+5,Length(s));
  a:=Pos(' ',s);
  if a = 0 then a:=Length(s);
  s:=Copy(s,1,a);

Jetzt musst du nur noch die Gänsefüßchen entfernen, wenn welche da sind. Ungetestet.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Sa 06.11.04 15:38 
Ich check deinen Code nicht.
Meinst du sowas?
ausblenden Quelltext
1:
2:
3:
4:
<!-- original Link -->
<a ... href="link.html" ... >text</a>
<!-- herauskommender Link ->
<a href="link.html">text</a>

???
Oder was willst du machen.

_________________
Klein, schwarz und ärgert Techniker? Jumper!
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 06.11.04 15:38 
Edit:
ausblenden Delphi-Quelltext
1:
  s:=Copy(s,Pos('href=',s)+5,Length(s));					

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
rabby Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

gentoo

BeitragVerfasst: Sa 06.11.04 16:58 
blackbirdXXX: es soll das ziel des links vor dem link als text(unverlinkt!) geschrieben werden.

Chef:danke, ich werds heut noch testen.