Skip to content

Instantly share code, notes, and snippets.

@baybatu
Last active January 26, 2016 07:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baybatu/a07593b73d464071b810 to your computer and use it in GitHub Desktop.
Save baybatu/a07593b73d464071b810 to your computer and use it in GitHub Desktop.
Parses credit card number with 16 characters into groups including 4 characters.
/*
* Example usage: parseCreditCard('1234567890123456') -> [ '1234', '5678', '9012', '3456' ]
*/
function parseCreditCard(cardNumber) {
return cardNumber.match(/.{1,4}/g);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment