JS能力测评40:判断是否包含数字

思路:

判断字符串中是否含有数字,可以用正则表达式。/\d/可以匹配字符串中的数字字符,用test方法可以检测。

function containsNumber(str) {
     var b = /\d/;
     return b.test(str);
 }

猜你喜欢

转载自blog.csdn.net/weixin_43160613/article/details/86522673