[英]Regex for 8 digits and after that 1 dot and after that only 2 digits
I need a regular expression for accepting eight digits and after that one dot and after that only two digits for amount fields.我需要一个正则表达式来接受八位数字,然后是一个点,之后只有两位数字用于金额字段。
Currently I'm using this much of code...目前我正在使用这么多代码......
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);
}
}
I just need an simple regular expression which helps me out.我只需要一个简单的正则表达式来帮助我。
您可以使用正则表达式: ^\\d{8}[.]\\d{2}$
[\d]{8}\.[\d]{2}
or或者
[0-9]{8}\.[0-9]{2}
https://regex101.com/r/SBAUc8/1 https://regex101.com/r/SBAUc8/1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.