更新时间:2023-02-26 10:54:54
如果您想要的只是一个,请使用 regex.test()
布尔结果:
Use regex.test()
if all you want is a boolean result:
/^([a-z0-9]{5,})$/.test('abc1'); // false
/^([a-z0-9]{5,})$/.test('abc12'); // true
/^([a-z0-9]{5,})$/.test('abc123'); // true
...你可以删除()
来自你的正则表达式,因为你不需要捕获。
...and you could remove the ()
from your regexp since you've no need for a capture.