![]() |
Reguläre Ausdrücke: erstes und letztes Vorkommen finden
Mit dieser Funktion kann man reguläre Ausdrücke auch in Delphi verwenden, allerdings wird TRegExpr (
![]()
Delphi-Quellcode:
Aufrufbeispiele:
function MatchExpression(Str, Expr : String; max : boolean = False) : String;
var i : Integer; begin with TRegExpr.Create do try ModifierG := False; Expression := Expr; if Exec(Str) then if(max) then begin repeat if(Match[i] <> '') then result := Match[i]; i := i + 1; until not ExecNext; end else Result := Match[1]; finally Free; end; end;
Delphi-Quellcode:
=> letzes Vorkommen Label1 zuweisen.
Label1.Caption := MatchExpression(Memo1.Text,'[HTML](.*)[/HTML]', true);
Delphi-Quellcode:
=> ersten Vorkommen Label1 zuweisen.
Label1.Caption := MatchExpression(Memo1.Text,'[HTML](.*)[/HTML]');
[edit=Chakotay1308]Beitrag überarbeitet. Mfg, Chakotay1308[/edit] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:59 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