![]() |
Delphi-Version: 10 Seattle
IBAN String Formatieren
Ich möchte gerne IBAN (Bankkontonummern) formatieren.
ich habe: einen String wie 'DE12123412341234123412' und ich möchte: 'DE 12 1234 1234 1234 1234 12' Das ist bestimmt ganz einfach, aber ich komme nicht drauf.
Delphi-Quellcode:
evtl. format('%S.....? |
AW: IBAN String Formatieren
Delphi-Quellcode:
uses
System.MaskUtils; var formattedIBAN: string; begin formattedIBAN := FormatMaskText('LL 00 0000 0000 0000 0000 00;0; ', 'DE12123412341234123412'); end; |
AW: IBAN String Formatieren
Schau Dir mal VCL.TMaskEdit an. Ich persönlich finde das ziemlich unschön, aber wenn Du es wirklich brauchst...
Edith sagt: Uwe war schneller... Sherlock |
AW: IBAN String Formatieren
Vielen Dank Ihr zwei..
|
AW: IBAN String Formatieren
Formatiert man das nicht immer in Blöcken zu vier Zeichen?
DE12 3456 7890 1234 5678 90 Das habe ich mal eine einfache Funktion gepackt.
Delphi-Quellcode:
Durch das schmale Leerzeichen wird wenig Platz verschwendet und es wird nicht umgebrochen.
const
cThinNoBreakSpace = #8239; // siehe https://de.wikipedia.org/wiki/Schmales_Leerzeichen function FormatIBAN(AIBAN: string; AThinNonBreakSpace: Boolean = False): string; var I: Byte; C: Char; begin Result := AIBAN; if AThinNonBreakSpace then C := cThinNoBreakSpace else C := #32; for I := 1 to 5 do Insert(C, Result, I * 5); end; |
AW: IBAN String Formatieren
Da ich sonst nie zum Regexen komm' :cry:, aber Einzeiler so ma ...
![]()
Delphi-Quellcode:
uses System.RegularExpressions;
var IBAN := 'DE12345678901234567890'; IBAN := TRegEx.Replace(IBAN, '(\w{4})', '$1 '); ShowMessage(IBAN);
Delphi-Quellcode:
oder statt
var IBAN := 'DE1234 5678901 234   567890';
IBAN := TRegEx.Replace(IBAN.Replace(' ', ''), '(\w{4})', '$1 '); ShowMessage(IBAN);
Delphi-Quellcode:
ein
\w
Delphi-Quellcode:
,
[A-Z0-9]
Delphi-Quellcode:
oder
[a-zA-Z0-9]
Delphi-Quellcode:
[[:alnum:]]
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:17 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