function RemoveMask(value) {
value = value.replace(/\./g, "");
return /\d+,\d+/.exec(value)[0].toString();
}
console.log(RemoveMask("R$5.000,00"));
console.log(RemoveMask("R$5.000,02"));
console.log(RemoveMask("Lorem Ipsum R$5.000,05 test"));
console.log(RemoveMask("Lorem Ipsum R$5.000,00 test"));
console.log(RemoveMask("Lorem Ipsum R$500,00 test"));
console.log(RemoveMask("Lorem Ipsum R$0,05 test"));
console.log(RemoveMask("Lorem Ipsum R$0,50 test"));
3条答案
按热度按时间soat7uwm1#
试试这个。
字符串
hec6srdp2#
slice
关闭货币符号,然后replace
其他:字符串
uhry853o3#
尝试一个支持多种货币的npm库,所以你不需要担心正则表达式:
字符串