UNPKG

@fremtind/jkl-formatters-util

Version:
20 lines (19 loc) 682 B
import { unicode } from "@fremtind/jkl-constants-util"; const KONTONUMMER_REGEX = { full: /^(\d{4})(\d{2})(\d{5})$/, partial: /^(\d{4})(\d{1,2})?(\d{1,5})?$/ }; function formatKontonummer(input, options) { const strippedInput = input.replace(/\W/g, ""); const regex = (options == null ? void 0 : options.partial) ? KONTONUMMER_REGEX.partial : KONTONUMMER_REGEX.full; const match = strippedInput.match(regex); if (!match) { return input; } return match.slice(1).filter(Boolean).join((options == null ? void 0 : options.separator) || unicode.NON_BREAKING_SPACE); } export { KONTONUMMER_REGEX, formatKontonummer }; //# sourceMappingURL=formatKontonummer.js.map