问题描述
我需要一个可以查看字符串的支票,看它是否包含任何
数字。
请帮助!
i need a check that can go through a string to see if it contains any
numbers.
Please help!
推荐答案
函数hasNumbers(t)
{
返回/\d/.test(t );
}
如果t包含数字则返回true,否则返回false。
-
Rob
function hasNumbers(t)
{
return /\d/.test(t);
}
Returns true if t contains numbers, otherwise false.
--
Rob
函数hasNumbers(t)
{
返回/\d/.test(t);
}
如果t包含数字,则返回true,否则返回false。
function hasNumbers(t)
{
return /\d/.test(t);
}
Returns true if t contains numbers, otherwise false.
如果t包含在l,则应该返回true east one
number,否则为false。
因此该函数应该被称为hasNumber()或hasDigit()。
-
Rob
That should probably be returns true if t contains at least one
number, otherwise false.
So the function should probably be called hasNumber() or hasDigit().
--
Rob
这篇关于检查字符串是否包含任何数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!