Last active
June 25, 2018 15:50
-
-
Save Troland/9b60c707f019175af28a112ced926781 to your computer and use it in GitHub Desktop.
// 银行号码位数分组
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
// 银行号码位数分组 | |
function groupCardNumber(cardNumber, digits) { | |
const re = new RegExp('\\d{'+ digits + '}', 'g'); | |
return bankNumber.replace(re, function (match, offset, string) { | |
if((offset + digits - 1) !== string.length - 1) { | |
match = match + ' '; | |
} | |
return match; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment