SOURCE

var num = 5;
var str = '5';
var regNum = new RegExp(num);
var regStr = new RegExp(str);

console.log(regStr,regStr.test(num));
console.log(num.match(regNum));
console.log(str.match(regNum));
console 命令行工具 X clear

                    
>
console