bahtrext
Version:
BahtText Stringify
10 lines (7 loc) • 321 B
JavaScript
export default (money) => {
const match = money.match(/(\d*)(\.\d+)?/);
if (!match) return [money, "", ""]; // Handle case where match fails
const [moneyFull, moneyInt, moneyFrac] = match;
const nmoneyFrac = moneyFrac ? moneyFrac.replace(/^\./, "") : "";
return [moneyFull, moneyInt, nmoneyFrac];
};