What is the RegEx to put whitespace per 4 characters
For example I have an IBAN number like this
BE45898287271283
I want to format it like this
BE45 8982 8727 1283
Any help is appreciated.
What is the RegEx to put whitespace per 4 characters
For example I have an IBAN number like this
BE45898287271283
I want to format it like this
BE45 8982 8727 1283
Any help is appreciated.
 
    
    You can try this
string test = "BE45898287271283";
test = Regex.Replace(test, ".{4}", "$0 ").Trim();
 
    
    Try this regex instead:
[a-z\d]{4}
string in="BE45898287271283";
string out = Regex.Replace("(?i)([a-z\\d]{4})", "$1 ");
 
    
    private string Group4(string s)
{
    string output="";
    for(int i=0; i < s.Length; i+=4)
        output+=s.Substring(i, 4) + ' ';
    return s.TrimEnd();
}
