Cecil
19+ years progress programming and still learning.
Hi all.
I am trying to find an industry standard for displaying credit card numbers. Easy I here you cry. However credit card numbers range from 12 to 19 digits long.
Now I don't want to do credit card validation. I just want to write a function which displays these formats depending of there length. i.e. if I pass 1234444556778888 returns 1234 4445 5677 8888
I have created a table of what I think the display formats should be. If any one could correct or point me in the right direction. Thanks
xxxx xxxx xxxx 12 4 + 4 + 4
1111 2222 3333 12
xxxx xxx xxx xxx 13 4 + 3 + 3 + 3
1111 222 333 444 13
xxxx xxxxx xxxxx 14 4 + 5 + 5
1111 22223 33344 14
xxxxxx xxx xxx xxx 15 6 + 3 + 3 + 3
111111 222 333 444 15
xxxx xxxx xxxx xxxx 16 4 + 4 + 4 + 4
1111 2222 3333 4444 16
xxxx xxxx xxxx xxxx x 17 4 + 4 + 4 + 4 + 1
1111 2222 3333 4444 5 17
xxxx xxxx xxxx xxxx xx 18 4 + 4 + 4 + 4 + 2
1111 2222 3333 4444 55 18
xxxx xxxx xxxx xxxx xxx 19 4 + 4 + 4 + 4 + 3
1111 2222 2222 3333 444 19
I am trying to find an industry standard for displaying credit card numbers. Easy I here you cry. However credit card numbers range from 12 to 19 digits long.
Now I don't want to do credit card validation. I just want to write a function which displays these formats depending of there length. i.e. if I pass 1234444556778888 returns 1234 4445 5677 8888
I have created a table of what I think the display formats should be. If any one could correct or point me in the right direction. Thanks
xxxx xxxx xxxx 12 4 + 4 + 4
1111 2222 3333 12
xxxx xxx xxx xxx 13 4 + 3 + 3 + 3
1111 222 333 444 13
xxxx xxxxx xxxxx 14 4 + 5 + 5
1111 22223 33344 14
xxxxxx xxx xxx xxx 15 6 + 3 + 3 + 3
111111 222 333 444 15
xxxx xxxx xxxx xxxx 16 4 + 4 + 4 + 4
1111 2222 3333 4444 16
xxxx xxxx xxxx xxxx x 17 4 + 4 + 4 + 4 + 1
1111 2222 3333 4444 5 17
xxxx xxxx xxxx xxxx xx 18 4 + 4 + 4 + 4 + 2
1111 2222 3333 4444 55 18
xxxx xxxx xxxx xxxx xxx 19 4 + 4 + 4 + 4 + 3
1111 2222 2222 3333 444 19