![]() |
String vorne mit Nullen auffüllen
Hallo! Ich habe einen String mit einer Länge<=8, und will diesen jetzt bis zur Länge 8 vorne mit Nullen auffüllen.
Es gibt sone Routine Format oder FormatStr glaub ich, aber ich bin eine absolute Niete in regulären Audrücken. Wie mache ich das? |
Re: String vorne mit Nullen auffüllen
Das hat nichts mit regulären Ausdrücken zu tun.
Delphi-Quellcode:
S := IntToStr(MyIntValue);
S := StringOf('0', 8 - Length(S)) + S; |
Re: String vorne mit Nullen auffüllen
Zitat:
Delphi-Quellcode:
deinstring := Format('%.08d', [deininteger]);
|
Re: String vorne mit Nullen auffüllen
Format hat was mit regulären Ausdrücken zu tun. Danke @all.
|
Re: String vorne mit Nullen auffüllen
Nachtrag zu jbg's Beitrag: Die Funktion heisst StringOfChar()
Delphi-Quellcode:
S := IntToStr(MyIntValue);
S := StringOfChar('0', 8 - Length(S)) + S; |
Re: String vorne mit Nullen auffüllen
Zitat:
Zitat:
|
Re: String vorne mit Nullen auffüllen
Ich hab eh grade gemerkt, dass IntToHex den Parameter "Digits" unterstützt.
|
Re: String vorne mit Nullen auffüllen
Zitat:
Delphi-Quellcode:
hexstring := Format('%.08X', [deininteger]); // grosse Buchstaben A-F in der Hexzahl
hexstring := Format('%.08x', [deininteger]); // kleine Buchstaben a-f in der Hexzahl |
Re: String vorne mit Nullen auffüllen
Zitat:
Ums kurz zu machen: Die Formatierungsausdrücke für die Funktion Format/FormatStr sind *keine* regulären Ausdrücke. |
Re: String vorne mit Nullen auffüllen
Nicht? Sieht aber genau so aus.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:36 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