![]() |
Re: Kommentare aus einem CSS-Code löschen
es läuft meistens auch ohne diesen, der war ja nur wegen der eventuell ungewollten Wortverbindungen.
Ich hatte keine Ahnung, das insert keine Konstanten mag -.-''
Delphi-Quellcode:
So, um jetzt noch die überflüsigen Leerzeichen rauszuholen...
function ClearCommentarTStrings(Inhalt:TStrings):String;
var i, beg_com, end_com: integer; myInhalt, L: string; begin CommentCount := 0; L := ' '; for i := 0 to Inhalt.Count -1 do myInhalt := myInhalt + ' ' + Trim(Inhalt.Strings[i]); while true do begin beg_com:=Pos('/*', myInhalt); end_com:=Pos('*/', myInhalt); if (beg_com > 0) and (end_com > beg_com) then begin inc(CommentCount); delete(myInhalt, beg_com, end_com-beg_com+2); insert(myInhalt, L, beg_com); end else Break; end; Result:=myInhalt; end; in den BadChars sind die Zeichen, die nicht zusammenkommen dürfen (ich weiß jetzt nicht, ob das alle Zeichen sind, oder ob 1-2 zuviel sind)
Delphi-Quellcode:
uses StrUtils;
var CommentCount: Integer; function ClearCommentarTStrings(Inhalt:TStrings):String; const BadChars: set of Char = ['-', '.', '0'..'9', '@', 'A'..'Z', '_', 'a'..'z', '|', '~'..#255]; var i, beg_com, end_com: integer; myInhalt, L: string; begin CommentCount := 0; L := ' '; for i := 0 to Inhalt.Count -1 do myInhalt := myInhalt + ' ' + Trim(Inhalt.Strings[i]); while true do begin beg_com := Pos('/*', myInhalt); end_com := Pos('*/', myInhalt); if (beg_com > 0) and (end_com > beg_com) then begin inc(CommentCount); delete(myInhalt, beg_com, end_com-beg_com+2); insert(myInhalt, L, beg_com); end else Break; end; for i := 1 to length(myInhalt) do if myInhalt[i] < ' ' then myInhalt[i] := ' '; myInhalt := Trim(myInhalt); i := 2; while PosEx(' ', myInhalt, i) > 0 do begin i := PosEx(' ', myInhalt, i); if (not (myInhalt[i - 1] in BadChars)) or (not (myInhalt[i + 1] in BadChars)) then delete(myInhalt, i, 1) else Inc(i); end; Result:=myInhalt; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:40 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 by Thomas Breitkreuz