![]() |
TrimChars für beliebige Zeichen
xaromz zeigt
![]()
Delphi-Quellcode:
Hier zwei Beispielaufrufe:
type
TTrimDirection = set of (tdLeft, tdRight); function PATrimChars(const S: String; CS: TSysCharSet; Direction: TTrimDirection): String; var L, Left, Right: Integer; begin L := Length(S); Left := 1; if tdLeft in Direction then begin while (Left <= L) and (S[Left] in CS) do Inc(Left); if Left > L then begin Result := ''; Exit; end; end; Right := L; if tdRight in Direction then begin while (Right > 0) and (S[Right] in CS) do Dec(Right); end; Result := Copy(S, Left, Right - Left + 1); end;
Delphi-Quellcode:
[edit=CalganX]Aktualisierter Quellcode. Mfg, CalganX[/edit]
ShowMessage(PATrimChars('hallo!!!', ['!'], [tdRight])); // ergibt: hallo;
ShowMessage(PATrimChars('_#hallo/{', ['_', '#', '/', '{'], [tdLeft, tdRight])); // ergibt: hallo; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:04 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