2025-03-26
This commit is contained in:
17
src/utils/regexp/numberRexg1.ts
Normal file
17
src/utils/regexp/numberRexg1.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
//前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];
|
||||
};
|
||||
Reference in New Issue
Block a user