qualRegex返回upVoters: {
type: [String],
label: 'Up Voters',
defaultValue: [this.userId],
optional: true,
autoform: {
type: "hidden"
}
},
和false
。我使用代码true
检查SIN编号是否为9位。我需要代码来计算4位小数。因此,如果任何数字超过4位小数,则返回^([0-9]{9})$
。什么是4位小数的代码。
答案 0 :(得分:0)
你需要这个正则表达式吗?
^\d+\.\d{0,4}$
const regex = /^\d+\.\d{0,4}$/gm;
const str = `24.1
24.12
24.123
24.1234
25.12345
25.123737`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}