Working on a rails project where there’s an order confirmation string with a credit card number with all but the last four digits starred out. What’s the proper way to do a string substitution?
What’s the operation to get this
credit_card_number = "1111111111111111"
to this?
credit_card_number = "************1111"
Thanks,
Kenji
If you’re using ActiveMerchant,
ActiveMerchant::Billing::CreditCardhas an instance method calleddisplay_numberwhich does this e.g. XXXX-XXXX-XXXX-4338If you’re not, copy activemerchant: