Last active
November 26, 2021 15:23
-
-
Save lnt/07eded85cf90d0f1288591d71938a6c7 to your computer and use it in GitHub Desktop.
Mask Debit/Credit Card number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maskCard = (str)=> | |
str.replace(/\b(?:\d{4}[ - ]?){3}(?=\d{4}\b)/gm,'#### #### ####'); | |
maskCard('visa 1234 3456 4567 5678') | |
// 'visa #### #### ####5678' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment