Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data annotations - DisplayFormat - formatting string of numbers

I have the following string: "10222002750400447092095835"

I want it to be displayed like this: 10 2220 0275 0400 4470 9209 5835

I tried doing the following, with no result at all:

[DisplayFormat(DataFormatString = "{0:00 0000 0000 0000 0000 0000 0000}", ApplyFormatInEditMode = true)]

or

[DisplayFormat(DataFormatString = "{0:## #### #### #### #### #### ####}", ApplyFormatInEditMode = true)]

What am I doing wrong?

like image 789
ojek Avatar asked May 21 '26 19:05

ojek


1 Answers

I believe what you are looking for is String masking. See below.

Stackoverflow - How to mask a string Stackoverflow - Apply mask to string

like image 172
James Shaw Avatar answered May 23 '26 08:05

James Shaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!