[英]Regex for 8 digits and after that 1 dot and after that only 2 digits
我需要一個正則表達式來接受八位數字,然后是一個點,之后只有兩位數字用於金額字段。
目前我正在使用這么多代碼......
valLowLTL(val) {
const val1 = val.split('.');
const amountLowLTL = this.addBillingForm.get('invoicingAmtLowLTL') as FormControl;
const re = /,/gi;
val1[0] = val1[0].replace(re, '');
if (val1[0].length > 8) {
val1[0] = val1[0].substring(0, 8);
}
amountLowLTL.setValue(val1[0]);
if (val1.length > 1) {
if (val1[1].length > 2) {
val1[1] = val1[1].substring(0, 2);
}
const lowValLTL = val1[0].concat('.').concat(val1[1]);
amountLowLTL.setValue(lowValLTL);
}
}
我只需要一個簡單的正則表達式來幫助我。
您可以使用正則表達式: ^\\d{8}[.]\\d{2}$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.