"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Format bank account number to format like XXX-XXXXXX-XXX (separator can be customized)
*
* @param value The original bank account number value
* @param separator Customized separator. Default to hyphen '-'.
* @category number
* @module formatBankAccNum
*/
var formatBankAccNum = function (value, separator) {
if (separator === void 0) { separator = '-'; }
var rawNumber = value.replace(/[^\d]/g, '');
var matchedNumber = rawNumber.match(/^(\d{0,3})(\d{0,6})(\d{0,3})/);
// MatchedNumber will be in format of [ wholeNumber, firstGroup, secondGroup, thirdGroup ]
if (matchedNumber) {
// Drop the first segment (wholeNumber), and remove empty segment
var activeSegments = matchedNumber.slice(1).filter(function (s) { return s !== ''; });
return activeSegments.join(separator);
}
return '';
};
exports.default = formatBankAccNum;
Source