18 lines
697 B
TypeScript
18 lines
697 B
TypeScript
//前3后4
|
|
export const numberRexg1 = (value: any) => {
|
|
if (!value) {
|
|
return;
|
|
}
|
|
if (value.toString().indexOf(".") != -1) {
|
|
let value_after = parseInt(value.toString().substring(0, value.indexOf(".")));
|
|
let value_before = value.replace(/\d+\.(\d*)/, "$1");
|
|
if (value_after.toString().length > 3) {
|
|
let newValue = value_after.toString().substring(0, 3) + "." + value_before;
|
|
return (newValue.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
|
|
} else {
|
|
return (value.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
|
|
}
|
|
}
|
|
return (value.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
|
|
};
|