Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Prüfen ob zeichen in HTML-Tag ist (https://www.delphipraxis.net/43183-pruefen-ob-zeichen-html-tag-ist.html)

glkgereon 30. Mär 2005 10:57


Prüfen ob zeichen in HTML-Tag ist
 
hi

ich brauche eine procedure die prüft, ob das zeichen "Index" des Textes "Text" in einem HTML-Tag liegt oder nich.

hier mein versuch:
Delphi-Quellcode:
function isHTMLTag(Text: String; Index: Integer): Boolean;
var Schluss: Char;
begin
  //Anfang
    if Text[Index]='<' then
      begin
      //ist Schluss-Tag?
      if Text[Index+1]='/' then Inc(Index);
      //Komplex oder Einfach?
      if (PosEx(' ',Text,Index)<PosEx('>',Text,Index)) and (PosEx(' ',Text,Index)>0) then Schluss:=' ' else Schluss:='>';
      //Abfrage
      Result:=HTMLIdent(copy(Text,Index+1,PosEx(Schluss,Text,Index)-Index-1));
      end
    else if Text[Index]='>' //von neuem aufrufen mit indes des Anfangs
      then Result:=isHTMLTag(Text,LastDelimiter('<',copy(Text,1,Index)))
    else if Text[Index]='/' //Html und XHtml-Konform
      then Result:=(Text[Index-1]='<') xor (Text[Index+1]='>')
      //im tag?
    else Result:=LastDelimiter('<',copy(Text,1,Index)) > LastDelimiter('>',copy(Text,1,Index));
end;
was noch fehlt:
es erkennt keine kommentare.
hat da einer ne idee wie das gehen könnte?

natürlich siond auch weitere verbesserungen erwünscht ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz