function toHex(num){
var rs = "";
var temp;
while(num/16 > 0){
temp = num%16;
rs = (temp+"").replace("10","a").replace("11","b").replace("12","c").replace("13","d").replace("14","e").replace("15","f") + rs;
num = parseInt(num/16);
}
console.warn(rs); //打印
return rs;
}
备注:以上就是10进制转16进制的js了,求红色代码的正则表达式!!!