In my android app, I have this format xxxx xxxx xxxx xxxx
for credit card number but when I insert AMEX with 15 digits I want it to be shown as xxxx xxxx xxxx 1234
Instead, I get xxxx xxxx xxx1 234
.
How do I fix this?
I'm using this code:
textCardNumber.setText("Card Number: " + mActivity.maskedAccountNumber.replaceAll("(.{4})(?!$)", "$1 "));